This topic is now archived and is closed to further replies.

Arek the Absolute

constants in multiple source files

Recommended Posts

Why is it I''m having so much trouble with something like this silly? I must be getting tired and just forgetting something stupid. Anyway, my problem is using G++ for a GBA application, but this isn''t GBA specific. In one source file I have something like this: const int array[5] = {0,1,2,3,4}; and in another source file I have this: extern const int array[5]; and whenever I try to use the array in that other source file (the one that defines it as extern) the linker tells me I have an "undefined reference to ''array''" If I make the variable simply an int, (not const) then everything works fine. It''s real important that I make sure this array is constant, so what am I missing here? There''s got to be a way to share const arrays between multiple source files... -Arek the Absolute

Share this post

Link to post
Share on other sites