constants in multiple source files

Started by
-1 comments, last by Arek the Absolute 21 years, 6 months ago
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
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig

This topic is closed to new replies.

Advertisement