Question about -ansi flag, and different size of struct from C and C++
Sergei Organov
osv at topconrd.ru
Mon Dec 15 12:55:37 UTC 2003
Oleg Ivanov <Belinus at zelax.ru> writes:
> 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.
>
When you rely on such a non-standard feature as 'packed struct', there is
absolutely no reason to give -ansi flag to the compiler. I believe the sole
purpose of -ansi flag while compiling RTEMS is a [weak] attempt to make sure
the sources are ANSI C and don't have any GNUisms.
> So I have two question, is there another method to ask C++ packed struct,
> and do we really need -ansi flag to compile rtems ?
I think you can remove -ansi flag.
Anyway, as far as I remember, once I've solved similar problem by defining a
structure like this:
typedef struct {
...
} __attribute__((packed)) dummy;
--
Sergei.
More information about the users
mailing list