spy v1.1.0
Julienne Aisner
 
Loading...
Searching...
No Matches

◆ compiler

constexpr compiler_type spy::compiler
inlineconstexpr

Compiler reporting value.

The spy::compiler object can be compared to any other compiler related value to verify if the code being compiled with a specific compiler.

Any compiler related value can be checked for equality or ordering for a given version. The targeted version is then specified using a compiler-dependent literal.

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

Supported Value

Name Compiler
spy::clang Clang
spy::dpcpp Intel DPC++/ICPX
spy::emscripten Emscripten
spy::gcc G++
spy::intel Intel ICC
spy::msvc Microsoft Visual Studio
spy::nvcc NVIDIA NVCC

Example

#include <spy/spy.hpp>
#include <iostream>
int main()
{
// Comparisons
if constexpr( spy::compiler == spy::gcc_ ) std::cout << "This code compiled with g++.\n";
else if constexpr( spy::compiler == spy::clang_ ) std::cout << "This code compiled with clang.\n";
else if constexpr( spy::compiler == spy::dpcpp_ ) std::cout << "This code compiled with ICPX.\n";
// Direct test
if constexpr( spy::gcc_ ) std::cout << "This code compiled with g++.\n";
else if constexpr( spy::clang_ ) std::cout << "This code compiled with clang.\n";
else if constexpr( spy::dpcpp_ ) std::cout << "This code compiled with ICPX.\n";
//Version checks
using namespace spy::literal;
if constexpr( spy::compiler == 16'0_clang ) std::cout << "This code compiled with clang 16.\n";
if constexpr( spy::compiler >= 15'0_clang ) std::cout << "This code compiled with clang 15 or ulterior.\n";
}
constexpr compiler_type compiler
Compiler reporting value.
Definition: compiler.hpp:125