Problem with code or gcc?

John Love-Jensen eljay@adobe.com
Tue Sep 27 15:14:00 GMT 2005


Hi Artur,

> Shouldn't I get a linker error in those other cases?

Not necessarily.

You won't get a linker error if the actual numeric value can be used "as
is", without referencing the variable it is associated with.  Consider it an
optimization of sorts.

If you really dislike this situation[1], you can use enum for your integer
constants in your struct.

[1] I actually PREFER coding like in your example.  But I know quite a few
C++ software engineers that prefer using enums for constants instead --
they'd claim there are "less surprises".  Both idioms will be supported by
C++ for a very long time.

Sincerely,
--Eljay



More information about the Gcc-help mailing list