3

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.

Stan E
  • 3,066
  • 15
  • 29
  • 9
    Compile with `-std=C++03` ? – Jarod42 Apr 23 '15 at 07:45
  • 4
    If using `g++` simply compile with `-std=c++03` which will disable all C++11 feature support, generating errors if any are encountered in your source code. – Nik Bougalis Apr 23 '15 at 07:46
  • So, am I understanding it right you guys, compiling without c++11 support will just fail the building? – Stan E Apr 23 '15 at 07:54
  • 3
    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 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. – senfen Apr 23 '15 at 07:57

1 Answers1

7

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...

senfen
  • 825
  • 5
  • 21
  • 1
    There is surprisingly a lot of [code that will behave differently in C++03 compared to C++11](http://stackoverflow.com/a/23063914/1708801) – Shafik Yaghmour Apr 23 '15 at 09:06