- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Thanks,
Olivier
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page