【发布时间】:2014-02-18 00:10:07
【问题描述】:
即使尝试了所有头文件包含的顺序, 我仍然收到 netinet/in.h 的错误
/usr/include/netinet/in.h:34: error: expected identifier before numeric constant
我已经包含了以下头文件
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/select.h>
#include <fcntl.h>
#include <sys/types.h>
#include <errno.h>
#include <netinet/ip.h>
#include <netinet/in.h>
如何消除此错误? 我用 gcc -g3 -Wall 编译。
【问题讨论】:
-
netinet/in.h尝试定义IPPROTO_IP,它已经在您的代码中由netinet/ip.h定义。如果您切换这 2 个包含的顺序,那应该可以工作。