c++11 - Simplest C++ Example to verify my compiler is c++14 compliant? -


i taking class next week on c++11/14 , need verify design tools date , can compile c++11/14.

what simplest piece of code can put verify can compile , execute c++11/14 code on linux box? know need gcc 4.9.x or better, want sure jiving before show up.

thanks help.

you can compile -std=c++14. if gcc (or clang) not c++14 compliant compilation fail (due uknown flag) :

g++: error: unrecognized command line option '-std=c++14' 

regarding feature availability (querying existence of specific features), can perform feature testing. example document can found here : boils down use of macros test availability of specified feature (therein can find what features for).

so if want build several compilers can write code (naive example follows) :

#if __cpp_constexpr constexpr  #endif int triple(int k) { return 3*k; } // compiles c++98 

which how cross platform developing overcomes joys of supporting multiple compilers , versions (more elaborate examples show supporting sth 1 way in gcc , way in cl due different speed of standard implementation)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -