Utilities » Platform module

Cnx provides an assortment of platform detection macros to detect operating system, compiler, little vs big endianness, and architecture.

Enums

enum CnxPlatformArchitecture { CNX_PLATFORM_x86_64 = 1U << 1U, CNX_PLATFORM_X86 = 1U << 2U, CNX_PLATFORM_ARMv2 = 1U << 3U, CNX_PLATFORM_ARMv3 = 1U << 4U, CNX_PLATFORM_ARMv4 = 1U << 5U, CNX_PLATFORM_ARMv5 = 1U << 6U, CNX_PLATFORM_ARMv6 = 1U << 7U, CNX_PLATFORM_ARMv7 = 1U << 8U, CNX_PLATFORM_ARMv7a = (unsigned)(CNX_PLATFORM_ARMv7) | 1U << 9U, CNX_PLATFORM_ARMv7r = (unsigned)(CNX_PLATFORM_ARMv7) | (unsigned)(CNX_PLATFORM_ARMv7a) | 1U << 10U, CNX_PLATFORM_ARMv7m = (unsigned)(CNX_PLATFORM_ARMv7) | (unsigned)(CNX_PLATFORM_ARMv7a) | (unsigned)(CNX_PLATFORM_ARMv7r) | 1U << 11U, CNX_PLATFORM_ARMv7s = (unsigned)(CNX_PLATFORM_ARMv7) | (unsigned)(CNX_PLATFORM_ARMv7a) | (unsigned)(CNX_PLATFORM_ARMv7r) | 1U << 12U, CNX_PLATFORM_ARMv8 = 1U << 13U, CNX_PLATFORM_ARM64 = 1U << 13U, CNX_PLATFORM_MIPS = 1U << 14U, CNX_PLATFORM_SUPERH = 1U << 15U, CNX_PLATFORM_POWERPC = 1U << 16U, CNX_PLATFORM_POWERPC64 = 1U << 17U, CNX_PLATFORM_SPARC = 1U << 18U, CNX_PLATFORM_M68K = 1U << 19U, CNX_PLATFORM_UNKNOWN = 1U << 20U }
The list of supported architectures to compile for.

Typedefs

using CnxPlatformArchitecture = enum CnxPlatformArchitecture
The list of supported architectures to compile for.

Defines

#define CNX_PLATFORM_WINDOWS
Whether the compiled-for platform is WINDOWS.
#define CNX_PLATFORM_APPLE
Whether the compiled-for platform is APPLE (MacOS, IOS)
#define CNX_PLATFORM_UNIX
Whether the compiled-for platform is a variant of UNIX.
#define CNX_PLATFORM_LINUX
Whether the compiled-for platform is LINUX.
#define CNX_PLATFORM_BSD
Whether the compiled-for platform is BSD.
#define CNX_PLATFORM_ZOS
Whether the compiled-for platform is z/OS.
#define CNX_PLATFORM_ANDROID
Whether the compiled-for platform is ANDROID.
#define CNX_PLATFORM_HPUX
Whether the compiled-for platform is HPUX.
#define CNX_PLATFORM_AIX
Whether the compiled-for platform is AIX.
#define CNX_PLATFORM_SOLARIS
Whether the compiled-for platform is SOLARIS.
#define CNX_PLATFORM_COMPILER_CLANG
Whether the current compiler is CLANG.
#define CNX_PLATFORM_COMPILER_GCC
Whether the current compiler is GCC.
#define CNX_PLATFORM_DEBUG
Whether the current build mode is DEBUG.
#define CNX_PLATFORM_RELEASE
Whether the current build mode is RELEASE.
#define CNX_PLATFORM_LITTLE_ENDIAN
Whether the compiled-for architecture is a little endian architecture.
#define CNX_PLATFORM_BIG_ENDIAN
Whether the compiled-for architecture is a big endian architecture.
#define CNX_PLATFORM_ARCHITECTURE
The CPU architecture family being compiled for.
#define IS_CNX_PLATFORM_ARCHITECTURE(to_check)
Determines if the compiled-for architecture is the given one.

Enum documentation

enum CnxPlatformArchitecture

The list of supported architectures to compile for.

Typedef documentation

typedef enum CnxPlatformArchitecture CnxPlatformArchitecture

The list of supported architectures to compile for.

Define documentation

#define CNX_PLATFORM_WINDOWS

Whether the compiled-for platform is WINDOWS.

#define CNX_PLATFORM_APPLE

Whether the compiled-for platform is APPLE (MacOS, IOS)

#define CNX_PLATFORM_UNIX

Whether the compiled-for platform is a variant of UNIX.

#define CNX_PLATFORM_LINUX

Whether the compiled-for platform is LINUX.

#define CNX_PLATFORM_BSD

Whether the compiled-for platform is BSD.

#define CNX_PLATFORM_ZOS

Whether the compiled-for platform is z/OS.

#define CNX_PLATFORM_ANDROID

Whether the compiled-for platform is ANDROID.

#define CNX_PLATFORM_HPUX

Whether the compiled-for platform is HPUX.

#define CNX_PLATFORM_AIX

Whether the compiled-for platform is AIX.

#define CNX_PLATFORM_SOLARIS

Whether the compiled-for platform is SOLARIS.

#define CNX_PLATFORM_COMPILER_CLANG

Whether the current compiler is CLANG.

#define CNX_PLATFORM_COMPILER_GCC

Whether the current compiler is GCC.

#define CNX_PLATFORM_DEBUG

Whether the current build mode is DEBUG.

#define CNX_PLATFORM_RELEASE

Whether the current build mode is RELEASE.

#define CNX_PLATFORM_LITTLE_ENDIAN

Whether the compiled-for architecture is a little endian architecture.

#define CNX_PLATFORM_BIG_ENDIAN

Whether the compiled-for architecture is a big endian architecture.

#define CNX_PLATFORM_ARCHITECTURE

The CPU architecture family being compiled for.

Can be any of CnxPlatformArchitecture

#define IS_CNX_PLATFORM_ARCHITECTURE(to_check)

Determines if the compiled-for architecture is the given one.

Parameters
to_check - The platform architecture to check against. Must be one of the enum CnxPlatformArchitecture
Returns whether the compiled-for architecture is the given one

This will determine if the architecture being compiled for matches or is a super set of the given architecture to check for.