Platform Check Macros

C and C++ compilers automatically define some macros that can be used to:

  • Identify platforms (architecture, endianness, OS, compiler, C++ standard, library)
  • Detect compiler configurations (debug mode, exception handling, etc.)

Collectively, these macros are known as pre-defined compiler macros, and are used in Abseil to conditionally compile code for various purposes like portability, performance, functionality, etc. This document lists the compiler macros Abseil uses to write preprocessor conditionals and build configuration macros.

This document is designed solely to document Abseil’s usage of these macros, and assist developers who need to add architecture-specific code to Abseil.

Note: Feature Check Macros, which developers can use to check for the presence of certain language features, are documented within their own, separate guide.

The macros that Abseil uses are listed below, in tables that list the macro, what it identifies, and what standard defines the macro.

If you wish to check what macros your compiler has defined, see How to List Compiler Predefined Macros.


Macro Architecture Compiler Notes
__x86_64__ AMD64 GNU C, Clang/LLVM  
_M_X64 AMD64 Visual Studio  
__arm__ ARM   32-bit only
_M_ARM ARM Visual Studio  
__aarch64__ ARM64    
__i386__ Intel x86    
_M_IX86 Intel x86 Visual Studio*  
__ia64__ Intel Itanum (IA-64)    
_M_IA64 Intel Itanum (IA-64) Visual Studio  
_M_PPC PowerPC Visual Studio  
__myriad2__ Myriad2 Myriad Development Kit (Intel Movidius)  
__mips__ MIPS GNU C  

* Only defined for 32-bits architectures.



No standard portable pre-defined macro exists that can be used to determine endianness. Instead, Abseil defines the following macros in absl/base/config/h:



Operating Systems

Macro Operating System Compiler
__ANDROID__ Android Android NDK
__APPLE__ MacOS, iOS GNU C, Intel C++, and Apple LLVM
_WIN32 Windows For both 32-bit and 64-bit environments
__linux__ Linux Android NDK, GNU C, Clang/LLVM
__ros__ Akaros  
__Fushsia__ Fuchsia  



Macro Compiler Version Macro Notes
Clang also defines __GNUC__ for compatibility with GCC. If you want Clang-only, write defined(__GNUC__) && !defined(__clang__)
__clang__ Clang/LLVM __clang_major__
__EMSCRIPTEN__ Emscripten __EMSCRIPTEN_major__
__asmjs__ asm.js    
__wasm__ WebAssembly    
__NVCC__ NVCC    


  • Compilers within the Sourceforge Pre-defined Compiler Macros guide.


Library headers need to be included before checking the macros. For example, base/config.h includes <cstddef> for __GLIBCXX__, _LIBCPP_VERSION.

Note that these macros are not compiler-dependent as they are defined within header files.

Macro Library
__GLIBCXX__ libstdc++
__GLIBC__ GNU glibc
__BIONIC__ Bionic libc


  • Libraries within the Sourceforge Pre-defined Compiler Macros guide.