符号"符号"的偏移不一致

Offset of symbol 'Symbol' inconsistent

本文关键字:符号 不一致      更新时间:2023-10-16

有人能用一个例子向我解释一下PC Lint错误38吗。。。

38    Offset of symbol 'Symbol' inconsistent (Location)  -- A
      member of a class or struct appears in a different
      position (offset from the start of the structure) than an
      earlier declaration.  This could be caused by array
      dimensions changing from one module to another.

我总是犯这样的错误。。。

Offset of symbol 'ClassX::access1' inconsistent (conflicts with line 92, file U:ABCABCApp.h, module U:ABCABCApp.cpp) 

其中CCD_ 1是在CCD_ 3中声明的枚举CCD_。并且该枚举ACCESS被定义在不同的头文件access.h中。CCD_ 6包含在CCD_。

typedef enum
{
    ACCESS_NONE      = 0,
    ACCESS_READ      = 1
} ACCESS;

不确定这里出了什么问题。矛盾在哪里?

问题不在于ACCESS的定义,而在于access1成员在类access10中的位置。您要么有该类的双重声明,要么(很可能)有一些流氓#pragma pack,它在编译一个.cpp时有效,但在编译另一个.cpt时无效。