我已经为我的代码库运行了质量分析控制,并且我对看到的一些错误值有一些怀疑,如下所示:
这只是代码摘录
typedef struct UISR_caller_info_s/*structure declaration*/
{
unsigned char number[20];
unsigned char Name[30];
unsigned int numberType;
} caller_t;
static caller_t gs_val;/*variable of the structure type*/错误:
2027: strcpy((char *)gs_val.Name, NULL);
^
Msg(2:0310) Casting to different object pointer type.
REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics <next> 错误显示在char *类型转换中,我真的不知道为什么会发生这种情况。请告诉我如何避免这种错误
感谢GNR
发布于 2011-08-05 02:02:10
首先,strcpy调用可能会导致分段错误(并且肯定会导致未定义的行为)-您可能不希望NULL作为第二个参数。不管怎么说,你的电话不需要演员阵容:
strcpy(gs_value.Name, "");将工作得很好,这可能是您最初的意思。这可能是你的编译器非常挑剔,它抱怨从unsigned char到char的转换-你可以通过适当地改变你的结构来解决这个问题。
https://stackoverflow.com/questions/6946245
复制相似问题