This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Option to print word size, alignment on the target platform


Is there any option to ask GCC to print various size and alignment
info on the target platform?  This would be very nice during cross
compilation when one can not run the executables to autoconfigure for
such parameters.

Currently I consider for that a hack like copiling the following source:

#include <stddef.h>
union aligned_fields {
    double d;
    void (*f)();
    ...
};

struct align_test {
    union aligned_fields u1;
    char c;
};

const char DATA_POINTER_SIZE[sizeof(void *)];
const char FUNCTION_POINTER_SIZE[sizeof(void (*)())];
const char UNIVERSAL_ALIGN[offsetof(struct align_test, c)];
const char SHORT_SIZE[sizeof(short)];

and then running "nm --print-size" from binutils for the target on it to get:
00000004 00000004 C DATA_POINTER_SIZE
00000004 00000004 C FUNCTION_POINTER_SIZE
00000002 00000002 C SHORT_SIZE
00000008 00000008 C UNIVERSAL_ALIGN

But I doubt that this is reliable. So perhaps there is something like
gcc -print-target-info ?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]