gcc 编译 expected unqualified-id before '(' token 问题


我遇到这个问题是因为头文件的引用不当。具体原因我现在也不懂,但是我把头文件的引用顺序调整了一下就没问题了。


下面是我的头文件引用的具体情况:


①编译有问题的引用:

#include<string>
#include <iostream>
#include<fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sys/un.h>
#include <pthread.h>
#include <arpa/inet.h>
#include "apue.h"		//这里以下3个头文件改动顺序。
#include "get_set_time.cpp"
#include "node.cpp"
#include "DevConfig/GetSetIpDns.cpp"
#include "BroadCast/BroadCastReceiver.cpp"
#include "DevConfig/DevConfig.cpp"
#include "UniCast/UniCastReceiver.cpp"
#include "UniCast/UniCastSender.cpp"



②修改后编译没问题:

#include<string>
#include <iostream>
#include<fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdlib.h>
#include <sys/un.h>
#include <pthread.h>
#include <arpa/inet.h>
#include "DevConfig/GetSetIpDns.cpp"
#include "BroadCast/BroadCastReceiver.cpp"
#include "DevConfig/DevConfig.cpp"
#include "UniCast/UniCastReceiver.cpp"
#include "UniCast/UniCastSender.cpp"
#include "apue.h"			//3个头文件的引用放到最后。
#include "get_set_time.cpp"
#include "node.cpp"



你可能感兴趣的:(gcc,token)