On Wednesday 08 September 2004 12:57, John Lamb wrote:
Steven T. Hatton wrote:
No, I am specifically trying to initialize it at compile time. What the stupid compiler or linker is trying to do is a different story! ;) The code works if I build all the parts in the same compilation unit.
Fair enough, but look at it from the compiler's point of view. If you use a function to initialise a static const and the function is not defined in the same compilation unit, the compiler can't initialise the const at compile time. It's tricker, though I assume it's possible, to design a static linker that could do the additional compilation at link time to assign a value to the const. I think the gnu linker won't do it except, maybe, in simple cases.
I wonder if playing around with extern might work?
Did you mean to type "export". I don't think gcc handles export yet, but if you have any success with export (or extern) I'd like to know.
-- JDL
I finally figured out how to get it to build. I needed to have the library containing RgbColor linked into the final executable. I just added a -l to the g++ command line to get it to link. I'm pretty sure I can get the same result by adding a LIBADD or LDADD to the executable target. -- Regards, Steven