我正在努力完善一些现有的 C 代码,以便将其移植到新的编译器(嵌入式软件,我们正在切换硬件)。因此,我试图用 lint 清理当前代码,但我被 lint 判定为强类型违规的分配难住了。
我得到的错误:
--- Module: GenericFileName.c
GenericFileName.c ... Warning 632: Assignment to strong type
(SubStructureType_T) in context: assignment
它引用的代码行(为了便于阅读更改了名称):
void foo(void)
{
extern const StructureType_T parent;
const SubStructureType_T *localChild;
localChild = parent.child; //<-- lint complains about this assignment
...
}
StructureType_T的相关部分:
typedef struct
{
const struct SubStructureType_T *child;
...
}StructureType_T;
最后,启用强类型检查的 lint 选项:
-strong(AcXJcb)
任何见解将不胜感激。我已经四处寻找这方面的帮助,但没有找到太多。我猜 lint 是一个相当古老的工具。感谢阅读!
最佳答案
是const SubStructureType_T
,如foo
,还是const struct SubStructureType_T
,如typedef
?请注意,关键字“struct”仅出现在第二个定义中。
它们一样吗?
关于c - lint 中强类型检查的问题(警告 632),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7080805/