简体   繁体   English

检查是否使用了c ++ 11功能

[英]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. 所以,现在我的任务是检查整个代码中是否没有任何c ++ 11依赖项和功能。 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; -std=c++11 -Wc++98-compat +解析输出;

  • Boost.Config + a lot of macros around all the code, which seems more complicated then first one; Boost.Config +围绕所有代码的很多宏,这看起来比第一个更复杂;

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. 我正在多个平台上构建它,所以我可以在windows或linux上查看。

Reposting my comment. 重新发表评论。

Modern compilers got -std=c++11 as default. 现代编译器默认使用-std=c++11 Old ones need to explicit say we want c++11 by -std=c++11 . 旧的需要明确说我们希望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. 因此,使用-std=c++03会在所有C ++ 11构造中出错。

But this is no whole story. 但这不是一个完整的故事。 Some code can behave in different way in C++03 and C++11 but still compile! 有些代码可以在C ++ 03和C ++ 11中以不同的方式运行,但仍然可以编译! 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. 例如,静态初始化仅在C ++ 11中是线程安全的,因此在C ++ 03中,您将获得将编译但被窃听的代码。 Te be sure you need to review whole code with person who perfectly know C++03, C++11 and theirs differences. 确保你需要与完全了解C ++ 03,C ++ 11及其差异的人一起审查整个代码。

Probably you can support this work with tools for static code analysis but to be 100% sure you need to review it... 您可以使用静态代码分析工具支持这项工作,但要100%确定您需要查看它...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM