Walt Mankowski on 26 Apr 2004 20:44:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] #define for 32 vs 64 bit C program?


I have a C app that was developed on a 32 bit Linux box, and I'm
trying to get it to compile cleanly on a 64 bit opteron.  Does anyone
know of a gcc preprocessor directive that will tell whether a source
file is being compiled for 32 or 64 bits?

For example, I'd like to do something like this:

#include <stdio.h>

int main () {
        long i = 42;
#ifdef __32_BITS__
        printf("i = %d\n", i);
#else
        printf("i = %ld\n", i);
#endif
        return 0;
}

But I'm pretty sure that "__32_BITS__" isn't the right directive.
Does anyone know what the recommended way to do this is?

Thanks.

Walt

Attachment: signature.asc
Description: Digital signature