This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
using gcc __attribute__((packed,aligned(1))) works fine, but using g++ doesn't work. I tested -fshort-enums with gcc and g++ and works fine. Thanks everybody. Regards. Alle 10:38, mercoledì 11 dicembre 2002, Paul Whitfield ha scritto: > A simpler way to achieve what you want MAY be to add the command line > option for gcc > > -fshort-enums > > (Can't test this for your compiler type though!) > > Regards > > Paul > > Fabio Giovagnini wrote: > > Alle 10:02, mercoledì 11 dicembre 2002, Michael Svetlik ha scritto: > >>Fabio Giovagnini wrote: > >>>Hi everybody, > >>>that's my problem: > >>>if I define > >>>typedef struct ms{ > >>> unsigned long f1; > >>> unsigned long f2; > >>> unsigned char f3; > >>> } __attribute__((packed)) ms_t; > >>> > >>>unsigned char test; > >>> > >>>... > >>>... > >>>test = sizeof(ms_t); > >>>... > >>>... > >>> > >>>i see test == 9; > >>> > >>>if I delete attribure specifier, i see test = 12. > >>>This is the expected behaviour !!!! > >>> > >>>If I define > >>>typedef enum en {em_f1 = 0, em_f2, em_f3} > >>>__attribute__(((packed),aligned(1))) em_t; > >>> > >>>compiling with sh-hms-g++ 3.0.3 I have an error: missing semicolon .... > >>>instead compiling with sh-hms-gcc 3.0.3 everything works fine and the > >>> size is the expected size. > >>> > >>>If I define > >>>typedef enum en {em_f1 = 0, em_f2, em_f3} em_t > >>>__attribute__((packed,aligned(1))); > >>> > >>>no compiler error I see with sh-hms-g++ but the size is 4 that's > >>>unexpected size for this enum type if we suppose the __attribute__ > >>>keyword has been working. > > > > sorry, that's the rigth sintax: __attribute__((packed,aligned(1))) > > > >>I tried to compile the above statement with i686-linux-gnu gcc 2.95.3, > >>with g++ 2.95.3 and with g++ 3.1 - each of them from gnu.org, and each > >>of them returned an error - you have a tricky compiler. > >>What's the sense of packing a singular, scalar data type ? Do you want > >>to zip it :-? > > > > The sense is to save bytes if my enum type is lower than 255 values; I > > develop for embedded systems with few kbytes of ram; > > > >>What does your HITACHI do, when accessing a data type, bigger than one > >>byte, on an even address (aligned(1)) ? > > > > When I'm sure my enum type is lower than 255 values, an unsigned char is > > enougth. > > > >>You dont expect a size of 4 for your enum - what's the sizeof(int) on > >>your machine ? > > > > my sizeof(int) in 4, but I'd like to give my enum sizeof(unsigned char), > > and using gcc I can. > > > > Thanks. > > > >>>So I dedice the __attribute__ working in thuis sintax is not working, as > >>>someone said some time ago. > >>> > >>>Does anyone have some tips to understand and solve this problem? > >>> > >>>Regards. > >>> > >>> > >>>------ > >>>Want more information? See the CrossGCC FAQ, > >>>http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to > >>>crossgcc-unsubscribe@sources.redhat.com > >> > >>------ > >>Want more information? See the CrossGCC FAQ, > >>http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to > >>crossgcc-unsubscribe@sources.redhat.com > > > > ------ > > Want more information? See the CrossGCC FAQ, > > http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to > > crossgcc-unsubscribe@sources.redhat.com > > ------ > Want more information? See the CrossGCC FAQ, > http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to > crossgcc-unsubscribe@sources.redhat.com ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |