Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 811 Bytes

README.md

File metadata and controls

37 lines (29 loc) · 811 Bytes

detector

A header-only C++ library for checking the host os/compiler, and much more in a modern way.

Getting started

The library is header-only, so you just need to clone it from Github and #include it. That's all. No dependency. No #includes (it doesn't even depend on the standard library).

Example

#include <iostream>
    
void print_os()
{
    if (is_windows_v)
    {
        std::cout << "windows";
    }
    else if (is_linux_v)
    {
        std::cout << "linux";
    }
    else if (is_macos_v)
    {
        std::cout << "macos";
    }
}

int main()
{
    print_os();
}

NOTE: If your compiler supports at least C++17, you can use if constexpr instead of just if. There are other os-es checks supported. If you want to contribute, please create a(n) issue/pull request.