开发者

Problem with strong type-checking in lint (warning 632)

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!


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜