Is there a gcc macro that allows me to identify whether something is being compiled in 64bit mode?
Asked
Active
Viewed 5,059 times
2 Answers
3
Duplicate Question: Is there a GCC preprocessor directive to check if the code is being compiled on a 64 bit machine?
__LP64__
Seems to be what you want.

Community
- 1
- 1

Daniel Placek
- 765
- 5
- 16
-
1Note that on Windows, 64bit compiles are indicated by `__LLP64__` (yes, even with `gcc`). See http://blogs.msdn.com/b/oldnewthing/archive/2005/01/31/363790.aspx for details. – FrankH. Dec 09 '11 at 14:42
1
And you could also, at least on Linux,
#include <features.h>
#include <endian.h> // perhaps you skip that
#include <limits.h>
#include <stdint.h>
Then <bits/workdsize.h>
gets included and gives you __WORDSIZE
(either 64 or 32)
But why do you ask and why using the standard types provided by <stdint.h>
is not enough for you?

Basile Starynkevitch
- 223,805
- 18
- 296
- 547