[英]Does libstdc++ comply with MISRA C++?
This is motivated by a question that I made previously (on the same topic): 这是由我之前(在同一主题上)提出的一个问题引起的:
Do BLAS and LAPACK libraries comply with MISRA standard? BLAS和LAPACK库是否符合MISRA标准?
Now I have a much more important question: is libstdc++ (which is the implementation of the standard library by gcc) MISRA C++:2008 compliant? 现在,我有一个更加重要的问题: libstdc ++ (由gcc实现的标准库)是否符合MISRA C ++:2008? I assume the answer is yes ... as long as you compile your code with
gcc
and the -std=c++03
flag. 我认为答案是肯定的 ……只要您使用
gcc
和-std=c++03
标志编译代码即可。
What happens if I compile the code with the standard from 2011 (ie -std=c++11
)? 如果我使用2011年
-std=c++11
的标准(即-std=c++11
)编译代码,会发生什么情况? Is that MISRA C++:2008 compliant? 该MISRA C ++:2008是否兼容? Do I have to prove that the libstdc++ is MISRA compliant?
我是否必须证明libstdc ++符合MISRA? I can write deviations for a couple of rules (for example, I want to use
std::array
instead of C-style arrays), but writing them for the whole MISRA standard looks like a terryfying task. 我可以为一些规则写偏差(例如,我想使用
std::array
而不是C样式的数组),但是为整个MISRA标准编写它们似乎是一项艰巨的任务。
I would appreciate any insight into this topic. 如果您对此主题有任何见解,我将不胜感激。
No, it is not MISRA-C++ compliant. 不,它不符合MISRA-C ++的要求。 Neither is glibc.
glibc也不是。 But then there's no requirement from the standard that the library must be written in a certain language either.
但是从标准中也没有要求库也必须以某种特定的语言编写。 Standard compliance for the standard library itself is a rather muddy topic, with or without MISRA.
无论是否具有MISRA,标准库本身的标准合规性都是一个相当混乱的话题。
I very much doubt that MISRA-C++ is a priority for these libraries. 我非常怀疑MISRA-C ++是这些库的优先级。 The library (and gcc) maintainers are mostly from the Linux/Desktop ("hosted system") side of things, where MISRA compliance isn't required.
库(和gcc)的维护者主要来自Linux / Desktop(“托管系统”)方面,不需要MISRA合规性。
If you need a MISRA compliant standard library, you'll have to look at the various commercial embedded systems compilers. 如果需要符合MISRA的标准库,则必须查看各种商业嵌入式系统编译器。
What happens if I compile the code with the standard from 2011?
如果我使用2011年以来的标准编译代码会怎样? Is that MISRA C++:2008 compliant?
该MISRA C ++:2008是否兼容?
No it is not compliant. 不,它不符合要求。 MISRA-C++ requires explicitly that you use C++03, so it will be very hard to justify a deviation here.
MISRA-C ++明确要求您使用C ++ 03,因此在此处很难证明存在偏差。
Do I have to prove that the libstdc++ is MISRA compliant?
我是否必须证明libstdc ++符合MISRA?
There is no way to prove it, since it is not. 没有办法证明它,因为事实并非如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.