Help with gcc-3.1

Gokhan Kisacikoglu kisa@centropolisfx.com
Fri May 24 10:11:00 GMT 2002


The following compiles, but I think you've already figured it out;

------------------------------------------------------------------------
typedef struct { double x[3]; } Crd3;
typedef struct { Crd3 c; }      Rgb;

#define CRD3(_d0,_d1,_d2)       { (_d0), (_d1), (_d2) }
#define RGB(_r,_g,_b)           { CRD3((_r), (_g), (_b)) }

const Rgb RGB_WHITE =   RGB( 1.0, 1.0, 1.0 );

int main()
{
    return 0;
}
------------------------------------------------------------------------

I don't think putting the brackets into paranthesis is standard (ansi).
IMO, these types of constructs are much better dealt in c++, I think you
should migrate...

HTH,
Gokhan

Carl Eugen Hoyos wrote:
> 
> The following code is part of our project which compiles without warnings
> using gcc 2.95.2, 2.95.3 and 3.0.4
> If compiled with gcc 3.1, it produces errors. Can somebody tell me if this
> is a bug in gcc 3.1 or our code is not correct?
> Thank you, Carl Eugen Hoyos
> 
> -----------------------------------------------------------------
> typedef struct { double x[3];    } Crd3;
> typedef struct { Crd3 c; }      Rgb;
> 
> #define CRD3(_d0,_d1,_d2)       ((Crd3){{ (_d0), (_d1), (_d2) }})
> #define RGB(_r,_g,_b)           ((Rgb){CRD3( (_r),(_g),(_b) )})
> 
> const Rgb RGB_WHITE =   RGB( 1.0, 1.0, 1.0 );
> 
> int main()
> {
> return 0;
> }
> -----------------------------------------------------------------



More information about the Gcc-help mailing list