How can i figure out my architecture?

How can i figure out my architecture?

Hi,

Really need some help here and i am wondering if theres a way to do this so that any compiler can figure out if we are on 32bit or 64bit hardware.

Basically im trying to figure out if im on my itanium2 box or my p4 so my database will compile... but it doesnt work (im using the intel compiler)

#define SQLITE_PTR4 { sizeof(char *) == 4 }
#define SQLITE_PTR8 { sizeof(char *) == 8 }

#ifdef SQLITE_PTR4
#define SQLITE_PTR_SZ 4
#else
#define SQLITE_PTR_SZ 8
#endif

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I also tried this and it didnt work...

//find out bitsizes for architecture
#include

#if CHAR_BIT==4
#define SQLITE_PTR_SZ 4
#warning set to 4
#else
#define SQLITE_PTR_SZ 8
#warning set to 8
#endif

This seemed to work... maybe there is a better way?

//find out bitsizes for architecture
#include

#if __WORDSIZE == 64
#define SQLITE_PTR_SZ 8
#warning set to 8
#else
#define SQLITE_PTR_SZ 4
#warning set to 4
#endif

>>Basically im trying to figure out if im on my itanium2 box >>or my p4 so my database will compile... but it doesnt work >>(im using the intel compiler)

For this specific problem you can use compiler predefined macros.

i386 is defined for p4 and ia64 is defined for I2.

HTH,
Chandraprakash

Leave a Comment

Please sign in to add a comment. Not a member? Join today