lint 中的强类型检查存在问题(警告 632)
我正在努力完善一些现有的 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 是一个相当古老的工具。感谢您的阅读!
I'm working to polish some existing C code in order to port it to a new compiler (embedded software, we're switching hardware). So I'm trying to scrub the current code with lint, and I'm stumped by an assignment that lint has decided is a strong-typing violation.
The error I'm getting:
--- Module: GenericFileName.c
GenericFileName.c ... Warning 632: Assignment to strong type
(SubStructureType_T) in context: assignment
The lines of code to which it refers (names changed for readability):
void foo(void)
{
extern const StructureType_T parent;
const SubStructureType_T *localChild;
localChild = parent.child; //<-- lint complains about this assignment
...
}
The relevant parts of StructureType_T:
typedef struct
{
const struct SubStructureType_T *child;
...
}StructureType_T;
And finally, the lint option to enable strong-type checking:
-strong(AcXJcb)
Any insight would be greatly appreciated. I've searched around for help on this but haven't found much. I guess lint is a pretty old tool. Thanks for reading!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是像
foo
中那样的const SubStructureType_T
,还是像typedef
中那样的const struct SubStructureType_T
?请注意,关键字“struct”仅出现在第二个定义中。它们是一样的吗?
Is it
const SubStructureType_T
, as infoo
, orconst struct SubStructureType_T
as in thetypedef
? Note that the keyword "struct" only appears in the 2nd definition.Are they the same?