hookenz
hookenz

Reputation: 38907

Preprocessor macro to identify 64bit

Is there a gcc macro that allows me to identify whether something is being compiled in 64bit mode?

Upvotes: 2

Views: 5536

Answers (2)

Daniel Placek
Daniel Placek

Reputation: 765

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.

Upvotes: 3

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?

Upvotes: 2

Related Questions