Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if c++11 features are used or not

So, for now my task is to check if there is no any c++11 dependencies and features in the overall code. The question is - is it possible to check if there are any?

All I can imagine now can be divided into 2 groups:

  • -std=c++11 -Wc++98-compat + parsing the output;

  • Boost.Config + a lot of macros around all the code, which seems more complicated then first one;

Probably there could be built-in functionality in some static analyzers?

I'm building it on multiply platforms, so I can check either on windows or linux.

like image 403
Stan E Avatar asked Dec 01 '25 06:12

Stan E


1 Answers

Reposting my comment.

Modern compilers got -std=c++11 as default. Old ones need to explicit say we want c++11 by -std=c++11. You can explicit choose any standard you want. So use -std=c++03 gives you error on all C++11 construct.

But this is no whole story. Some code can behave in different way in C++03 and C++11 but still compile! For example static initialization is thread-safe only in C++11 so in C++03 you will get code which will compile but be bugged. Te be sure you need to review whole code with person who perfectly know C++03, C++11 and theirs differences.

Probably you can support this work with tools for static code analysis but to be 100% sure you need to review it...

like image 127
senfen Avatar answered Dec 03 '25 22:12

senfen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!