gpt4 book ai didi

c++ - 最高操作 'constant' 没有副作用 [MISRA 2004 Rule 14.2]

转载 作者:行者123 更新时间:2023-11-30 02:49:08 26 4
gpt4 key购买 nike

您好,这是我的代码的一部分,并针对此逻辑收到一些 MISRA 警告代码:

#define NASSERT(x) std::_nassert(x)

void fun(
const uint8_t * restrict src ,
uint8_t * restrict dst
){
NASSERT(((int32_t) src % 8) == 0); //line 1
NASSERT(((int32_t) dst % 8) == 0); //line 2
}

警告:(在第 1 行和第 2 行)

Warning 522: Highest operation, a 'constant', lacks side-effects [MISRA 2004 Rule 14.2]
Error 40: Undeclared identifier 'std'

你能指导我解决这个问题吗...

最佳答案

当您使用 C++ 编程时,您正在使用 C 语言的 MISRA 检查器。

MISRA C:2004 适用于 C 编程语言。

你应该使用 MISRA C++:2008 .

关于c++ - 最高操作 'constant' 没有副作用 [MISRA 2004 Rule 14.2],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21524430/

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