2

我正在努力完善一些现有的 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 是一个相当古老的工具。谢谢阅读!

4

1 回答 1

1

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

他们是一样的吗?

于 2011-08-16T15:55:49.523 回答