This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with code or gcc?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]