gpt4 book ai didi

c - 是否可以禁用外部库的 MISRA 检查?

转载 作者:行者123 更新时间:2023-12-01 17:33:40 28 4
gpt4 key购买 nike

是否可以禁用外部库的 MISRA 检查?我已经尝试过这个,但它似乎不起作用(此 header 使用 C++ 风格的注释和不兼容的 @ 标签)。

#pragma ghs startnomisra
#include <qcarcam.h>
#pragma ghs endnomisra

2018 年 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)添加到相关项目文件(例如, :

图书馆:

#!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 在内的所有内容都是必要的。

关于c - 是否可以禁用外部库的 MISRA 检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52149684/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com