是否可以禁用外部库的MISRA检查?我已经尝试过了,但是似乎不起作用(此标头使用C ++样式注释和不兼容的@标记)。
#pragma ghs startnomisra
#include <qcarcam.h>
#pragma ghs endnomisra
18年10月4日更新:最小示例
#pragma ghs startnomisra
#include <INTEGRITY.h>
#include <unistd.h>
#include <stdlib.h>
#pragma ghs endnomisra
int main(void)
{
const char* msg = "Hello world";
write(1, msg, strlen(msg));
Exit(0);
}
编译器输出:AFAIU这些行与#pragmas包含的内容有关
Output from Compiling stm-testbed_as0.c:
"/mnt/part2/apq8096au-hgh-1-0_hlos_dev_boot/ghs_apps_proc/integrity/INTEGRITY-include/INTEGRITY_types.h", line 226: error #20:
identifier "__inline" is undefined
static INLINE Value __LssbValue(Value TheValue)
^
"/mnt/part2/apq8096au-hgh-1-0_hlos_dev_boot/ghs_apps_proc/integrity/INTEGRITY-include/INTEGRITY_types.h", line 226: error #101:
"Value" has already been declared in the current scope
static INLINE Value __LssbValue(Value TheValue)
^
"/mnt/part2/apq8096au-hgh-1-0_hlos_dev_boot/ghs_apps_proc/integrity/INTEGRITY-include/INTEGRITY_types.h", line 226: error #65:
expected a ";"
static INLINE Value __LssbValue(Value TheValue)
^
"/mnt/part2/apq8096au-hgh-1-0_hlos_dev_boot/ghs_apps_proc/integrity/INTEGRITY-include/INTEGRITY_types.h", line 242: warning #12-D:
parsing restarts here after previous syntax error
typedef unsigned char MemoryLocation;
^
"/mnt/part2/apq8096au-hgh-1-0_hlos_dev_boot/ghs_apps_proc/integrity/INTEGRITY-include/time.h", line 67: fatal error #35:
#error directive: "(Misra Rule 20.12): the header <time.h> not
allowed"
# error "(Misra Rule 20.12): the header <time.h> not allowed"
^
最佳答案
您可以通过在相关项目文件中添加--misra_2004=none
(或--misra_2012=none
)来禁用每个库单元或每个文件的MISRA检查,例如:
图书馆:
#!gbuild
[Library]
-object_dir=$__OUT_DIR
-o $__OUT_DIR/lib/libfoo.a
--misra_2004=none
程序中的单个文件:
#!gbuild
[Program]
:
src/foo/bar.c
--misra_2004=none
我不知道为什么,但这对于包括
INTEGRITY.h
的所有内容都是必需的。