1834515 Members
2305 Online
110068 Solutions
New Discussion

Re: Finding 32 bit or 64

 
yatin
Frequent Advisor

Finding 32 bit or 64

I am writing ver simple helloworld like program .How can i detect whether i am compiling it for 32bit or 64 bit i tried LP64 bu it dint work here is the code

include

#ifdef LP64
#define var 64
#endif

#ifndef LP64
#define var 32
#endif

void main()
{
printf("%d",var);
}
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor

Re: Finding 32 bit or 64

if (sizeof (int *) == 8) {
printf ("64 bit\n");
}
else {
print "32bit\n";
}

cpp symbols you could look for are

_FILE_OFFSET_BITS
_ILP32
_LFS64_LARGEFILE

And as long as you don't state which compiler you use, it's pretty hard to guess what cpp symbols are defined. gcc has a different set of symbols as HP's C-ANSI-C

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
yatin
Frequent Advisor

Re: Finding 32 bit or 64

I got it it should be __LP64__ and not LP64