lint 中的强类型检查存在问题(警告 632)

发布于 2024-11-30 06:17:56 字数 816 浏览 4 评论 0原文

我正在努力完善一些现有的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-12-07 06:17:56

是像 foo 中那样的 const SubStructureType_T,还是像 typedef 中那样的 const struct SubStructureType_T?请注意,关键字“struct”仅出现在第二个定义中。

它们是一样的吗?

Is it const SubStructureType_T, as in foo, or const struct SubStructureType_T as in the typedef? Note that the keyword "struct" only appears in the 2nd definition.

Are they the same?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文