【发布时间】:2010-12-20 19:38:17
【问题描述】:
我收到“来自不兼容指针类型的赋值”的警告。我不明白为什么会发生此警告。除了整数之外,我不知道还有什么可以声明“the_go_status”变量。 (注意:这不是所有的代码,只是我贴出来的一个简化版本来说明问题。)
警告出现在我下面包含的示例的最后一行。
//In a header file
enum error_type
{
ERR_1 = 0,
ERR_2 = 1,
ERR_3 = 2,
ERR_4 = 4,
};
//In a header file
struct error_struct
{
int value;
enum error_type *status;
};
//In a C file
int the_go_status;
the_go_status = ERR_1;
//Have the error_struct "status" point to the address of "the_go_status"
error_struct.status = &the_go_status; //WARNING HERE!
【问题讨论】:
标签: c pointers enums warnings int