spy v3.0.0
Andrée Borrel
Loading...
Searching...
No Matches
Target Platforms

The system, the processor and the data model the code is compiled for. More...

Detailed Description

The system, the processor and the data model the code is compiled for.

Where the code will run. spy::operating_system names the system and spy::supports::posix_ says whether it offers a POSIX interface, spy::architecture names the processor family, and spy::data_model gives the sizes the ABI hands the fundamental types, which the system and the architecture decide together.

Variables

constexpr arch_type spy::architecture
 Architecture reporting value.
constexpr auto spy::data_model = data_model_type {}
 Data Model reporting value.
constexpr os_type spy::operating_system
 OS reporting value.
constexpr auto spy::supports::posix_ = spy_implementation_defined {}
 POSIX supports indicator.

Variable Documentation

◆ architecture

arch_type spy::architecture
inlineconstexpr

#include <spy/arch.hpp>

Architecture reporting value.

The spy::architecture object can be compared to any other architecture related value to verify if the code being compiled is compiled for a given CPU architecture.

Additionally, any of the architecture related value are convertible to bool. They evaluates to true if they matches the correct architecture currently targeted.

Supported Value

Name Architecture
spy::amd64 Intel X86-64 and similar architectures.
spy::arm ARM.
spy::ppc PowerPC.
spy::riscv RISC-V.
spy::wasm WASM pseudo-architecture.
spy::x86 Intel X86.

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
// Comparisons
if constexpr(spy::architecture == spy::x86_) std::cout << "This code is compiled for X86.\n";
else if constexpr(spy::architecture == spy::amd64_)
std::cout << "This code is compiled for X86-64.\n";
else if constexpr(spy::architecture == spy::ppc_)
std::cout << "This code is compiled for PowerPC.\n";
else if constexpr(spy::architecture == spy::arm_) std::cout << "This code is compiled for ARM.\n";
else if constexpr(spy::architecture == spy::riscv_)
std::cout << "This code is compiled for RISC-V.\n";
// Direct test
if constexpr(spy::x86_) std::cout << "This code is compiled for X86.\n";
else if constexpr(spy::amd64_) std::cout << "This code is compiled for X86-64.\n";
else if constexpr(spy::ppc_) std::cout << "This code is compiled for PowerPC.\n";
else if constexpr(spy::arm_) std::cout << "This code is compiled for ARM.\n";
else if constexpr(spy::riscv_) std::cout << "This code is compiled for RISC-V.\n";
}
constexpr arch_type architecture
Architecture reporting value.
Definition arch.hpp:103

◆ data_model

auto spy::data_model = data_model_type {}
inlineconstexpr

#include <spy/data_model.hpp>

Data Model reporting value.

The spy::data_model object can be compared to any other data model related value to verify if the code being compiled for a specific data model

Additionally, any of the data model related value are convertible to bool. They evaluates to true if they matches the correct data model currently used.

Supported Value

Name Data Model
spy::ilp32 ILP32
spy::lp32 LP32
spy::silp64 SILP64
spy::ilp64 ILP64
spy::llp64 LLP64
spy::lp64 LP64

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
// Comparisons
if constexpr(spy::data_model == spy::ilp32_)
std::cout << "This code is compiled on a ILP32 system\n";
else if constexpr(spy::data_model == spy::ilp64_)
std::cout << "This code is compiled on a ILP64 system\n";
else if constexpr(spy::data_model == spy::lp64_)
std::cout << "This code is compiled on a LP64 system\n";
// Direct test
if constexpr(spy::ilp32_) std::cout << "This code is compiled on a ILP32 system\n";
else if constexpr(spy::ilp64_) std::cout << "This code is compiled on a ILP64 system\n";
else if constexpr(spy::lp64_) std::cout << "This code is compiled on a LP64 system\n";
}
constexpr auto data_model
Data Model reporting value.
Definition data_model.hpp:68

◆ operating_system

os_type spy::operating_system
inlineconstexpr

#include <spy/os.hpp>

OS reporting value.

The spy::operating_system object can be compared to any other OS related value to verify if the code being compiled is compiled on a given Operating Systems.

Additionally, any of the OS related value are convertible to bool. They evaluates to true if they matches the correct OS currently used.

Supported Value

Name Operating System
spy::android_ Android
spy::bsd BSD
spy::cygwin_ CYGWIN
spy::ios_ iOS
spy::linux_ Linux
spy::macos_ MacOS
spy::unix_ UNIX
spy::windows_ Windows

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
// Comparisons
if constexpr(spy::operating_system == spy::bsd_) std::cout << "This code runs on BSD.\n";
else if constexpr(spy::operating_system == spy::linux_) std::cout << "This code runs on Linux.\n";
else if constexpr(spy::operating_system == spy::windows_)
std::cout << "This code runs on Windows.\n";
// Direct test
if constexpr(spy::bsd_) std::cout << "This code runs on BSD.\n";
else if constexpr(spy::linux_) std::cout << "This code runs on Linux.\n";
else if constexpr(spy::windows_) std::cout << "This code runs on Windows.\n";
}
constexpr os_type operating_system
OS reporting value.
Definition os.hpp:115

◆ posix_

auto spy::supports::posix_ = spy_implementation_defined {}
inlineconstexpr

#include <spy/os.hpp>

POSIX supports indicator.

Evaluates to true if current OS supports POSIX system calls and functions.

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
if constexpr(spy::supports::posix_)
{
std::cout << "This is a POSIX platform.\n";
}
}
constexpr auto posix_
POSIX supports indicator.
Definition os.hpp:150