How to check if compiler is C++17 with C++

1 Answer

0 votes
#include <iostream>
 
int main() {
    #if __cplusplus==201703L
        std::cout << "Compiler is C++17" << std::endl;
    #elif __cplusplus==201402L
        std::cout << "Compiler is C++14" << std::endl;
    #elif __cplusplus==201103L
        std::cout << "Compiler is C++11" << std::endl;
    #else
        std::cout << "C++" << std::endl;
    #endif
}

 
 
/*
run:
 
Compiler is C++17
 
*/

 



answered Apr 22, 2022 by avibootz

Related questions

1 answer 154 views
154 views asked Apr 22, 2022 by avibootz
1 answer 148 views
148 views asked Apr 22, 2022 by avibootz
1 answer 246 views
1 answer 292 views
1 answer 142 views
1 answer 158 views
158 views asked Apr 22, 2022 by avibootz
...