__attribute__((packed)); to make items of a
struct being stored in memory after another as this is critical for some low-level development.
__attribute__((packed)); is GCC specific I wonder if there is a similar solution that works on ALL ANSI/C89/C99/C11 compilers or at least some of them.
There is no standard approach to accomplish what
__attribute__((packed)) does. The typical solution is to use
#ifdef's to handle different compilers. You can find a few solutions to this approach at this SO post which also contains the details on the Visual C++ equivalent of
__attribute__((packed)). Alternatively, GCC supports the Windows struct packing pragmas, so if you are just concerned with Windows and GCC you could just use the Windows approach.
There is no support for features to control struct layout specified by the standard. The standard simply states that this aspect is implementation defined.
Therefore, if you do need to control layout, you will need to use compiler specific functionality. If you can find a way to avoid needing to do this at all, that would be preferable.