Question about -ansi flag, and different size of struct from C and C++

Camilo Alejandro Arboleda CamiloAlejo at netscape.net
Mon Dec 15 21:06:10 UTC 2003


There is a command line option of GCC (-fpack-struct) that makes *all* 
your structs packet. It could make your code binary incompatible with 
pre-comiled libraries.

Belinus at zelax.ru wrote:

>    Hello list,
>    I have a problem. I defined struct like:
>        struct dummy {
>          int var1;
>          short var2;
>          int var3;
>       } __attribute__ ((packed));
>
>    and access to it from C and C++ code.
>    The problem is that size from C is 10 bytes and from C++ is 12 
> bytes, I couldn't make that C++ packed that struct, exept removing 
> -ansi flag from compiler string.
>    So I have two question, is there another method to ask C++ packed 
> struct, and do we really need -ansi flag to compile rtems ?
>    Thanks
>
>
>

-- 
Your favorite stores, helpful shopping tools and great gift ideas. 
Experience the convenience of buying online with Shop at Netscape! 
http://shopnow.netscape.com/




More information about the users mailing list