G
Gowtham
Hi, I am trying to write some code which acts differently when
compiled on
32 bit and 64 bit machines. To identify the machine type, I am trying
to find
the sizeof( int ) and comparing it with 32 and 64.
But, the compiler is complaining about syntax errors in the #if lines.
Errors:
32-64.cpp:7:13: missing binary operator before '('
32-64.cpp:12:13: missing binary operator before '('
g++ version: 3.2.3
sizeof() is evaluated at compile time, and hence I am not able to
understand
why this code is not working:
code:
#include <iostream>
using namespace std;
int main( int argc, char *argv[] )
{
#if ( sizeof( int ) == 32 )
cout << "32 bit" << endl;
return 0;
#endif
#if ( sizeof( int ) == 64 )
cout << "64 bit" << endl;
return 0;
#endif
cout << "Neither 32 bit nor 64 bit" << endl;
}
Can somebody please tell me what I have missed?
Thanks
Gowtham
compiled on
32 bit and 64 bit machines. To identify the machine type, I am trying
to find
the sizeof( int ) and comparing it with 32 and 64.
But, the compiler is complaining about syntax errors in the #if lines.
Errors:
32-64.cpp:7:13: missing binary operator before '('
32-64.cpp:12:13: missing binary operator before '('
g++ version: 3.2.3
sizeof() is evaluated at compile time, and hence I am not able to
understand
why this code is not working:
code:
#include <iostream>
using namespace std;
int main( int argc, char *argv[] )
{
#if ( sizeof( int ) == 32 )
cout << "32 bit" << endl;
return 0;
#endif
#if ( sizeof( int ) == 64 )
cout << "64 bit" << endl;
return 0;
#endif
cout << "Neither 32 bit nor 64 bit" << endl;
}
Can somebody please tell me what I have missed?
Thanks
Gowtham