help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: g++ 3.3.2 '?:' operator compile error


From: Thomas Maeder
Subject: Re: g++ 3.3.2 '?:' operator compile error
Date: Sat, 01 May 2004 13:02:16 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux)

Kyuso Cahi <kyuso@softhome.net> writes:

> I have the following code that gives an error during compile:
>
> // xxx.cc
> class A {
>  public:
>   static const int YES=1;
>   static const int NO=-1;
> };
>
> int main() {
>   double n=3.0;
>   if (A::YES > A::NO); // line 9
>   return (n>0.0) ? (A::YES) : (A::NO); // line 10
> }
>
> ---after g++ 3.3.2 compiling--
> /tmp/ccCrBdd3.o(.text+0x33): In function `main':
> xxx.cc:10: undefined reference to `A::YES'
> /tmp/ccCrBdd3.o(.text+0x3d):xxx.cc:10: undefined reference to `A::NO'

Looks more like a linker error.


The program has undefined behavior: A::YES and A::NO are declared, but not
defined. What happens if you add

int const A::YES;
int const A::NO;

to the global namespace someplace after the definition of A?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]