This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with code or gcc?
- From: John Love-Jensen <eljay at adobe dot com>
- To: "Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA" <artur dot kedzierski at navy dot mil>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Tue, 27 Sep 2005 10:12:37 -0500
- Subject: 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