【c程序】expected identifier before numeric constant错误

在linux开发中,出现类似error: expected identifier before numeric constant错误。

原因:定义的enum结构体与其它处的宏定义有冲突。

举例说明

在文件a.h中:

     #define TRUE 1

在文件b.h中:

    typedef enum
    {
        FALSE=0,
        TRUE=1
    }bool;

在其他文件x.c中:

    #include "a.h"

    #include "b.h"

编译x.c文件会出现上述错误,主要原因定义的enum结构体与其它处的宏定义有冲突。在平时的开发中,定义宏的名称要特别注意,引用头文件时要做到规范。

猜你喜欢

转载自blog.csdn.net/u012503639/article/details/79722889