Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29359 Discussions

Is there a preprocessor variable that can be used to identify code architecture?

OP1
New Contributor III
717 Views
I would like to define a variable in my code that indicates whether the code was built as a 32-bit app for XP or a 64-bit app. Is there something similar to __DATE__, __TIME__ etc. to do this, so that the preprocessor can initialize a variable containing the information I am looking for?

Thanks,

Olivier
0 Kudos
4 Replies
Steven_L_Intel1
Employee
717 Views
Yes there is - _M_X64 is defined if building for Intel 64. You can see a list of all of the predefined symbols in the documentation under Building Applications > Preprocessing > Using Predefined Preprocessor Symbols.
0 Kudos
OP1
New Contributor III
717 Views
Yes there is - _M_X64 is defined if building for Intel 64. You can see a list of all of the predefined symbols in the documentation under Building Applications > Preprocessing > Using Predefined Preprocessor Symbols.

Thanks Steve. Now I can use something like:

! Retrieve the target architecture:
#IFDEF _M_X64
TARGET_X64 = .TRUE.
#ELSE
TARGET_X64 = .FALSE.
#ENDIF

It works great!

Olivier
0 Kudos
Steven_L_Intel1
Employee
717 Views
You could also test the value of INT_PTR_KIND() for being 4 or 8.

[plain]logical, parameter :: TARGET_X64 = INT_PTR_KIND() == 8
print *, TARGET_X64[/plain]

0 Kudos
rreis
New Contributor I
717 Views
You could also test the value of INT_PTR_KIND() for being 4 or 8.

[plain]logical, parameter :: TARGET_X64 = INT_PTR_KIND() == 8
print *, TARGET_X64[/plain]


oh, thats a nifty idea, I'll take note :) thx
0 Kudos
Reply