Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

is __attribute__ ((packed)) supported?

2008-04-15
2013-03-12
  • Daniel Fraile
    Daniel Fraile
    2008-04-15

    I'm porting old code that uses __attribute__ ((packed)) when declares some structs, for example:

    line 19: struct slotMiniSAE_t {
    line 20:    unsigned char cmd;
    line 21:    unsigned char flags;
    line 22: } __attribute__ ((packed));
    in sddc_rack_gestion.h header file. When I compile it with sdcc I find this error:

    /home/dfraile/proyectos/t8951/include/sdcc_rack_gestion.h:22: syntax error: token -> '(' ; column 18. The same piece of code compiles ok using Tasking compiler running on windows.

    What is wrong with that definition? Is there a way to achieve the same effect of packed attribute using command line options?

    Thanks

     
    • > is __attribute__ ((packed)) supported?

      no. On the other hand SDCC does not insert padding bytes to a get
      16 or 32 bit alignment anyway.
      You should be safe by simply adding an empty define:

      #define __attribute__(...)
      or
      #define __attribute__(x)

      somewhere before.

      > What is wrong with that definition?
      A "typedef" in line 18 or a variable name after the
      closing "}" in line 22 might be missing.