AMD64


Table of Contents

Description

The AMD64 architecture as defined by AMD and Intel.

Macros

TypeMacroDescription
Identification__amd64__ __amd64 __x86_64__ __x86_64Defined by GNU C and Sun Studio
Identification_M_X64 _M_AMD64Defined by Visual Studio

Notes

Note that the x32 ABI can be detected by checking if the CPU uses the ILP32 data model.

Run-time checking:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <stdio.h>

int
main(void)
{
  if (sizeof(int)    == 4 &&
      sizeof(long)   == 4 &&
      sizeof(void *) == 4)
  {
    printf("ILP32 detected (possibly x32 ABI)\n");
  } else {
    printf("Not ILP32\n");
  }

  return 0;
}
 

Compile-time checking:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <stdio.h>

int
main(void)
{
#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG__ == 4 && __SIZEOF_POINTER__ == 4
  printf("ILP32 detected\n");
#else
  printf("Not ILP32\n");
#endif

  return 0;
}
 

compile-time checking for systems that provide __ILP32__:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <stdio.h>

int
main(void)
{
#if defined(__x86_64__) && defined(__ILP32__)
  printf("x32 ABI detected\n");
#else
  printf("Not x32 ABI\n");
#endif

  return 0;
}
 
 
Return to top
 
Created: