我有三個文件,說AC,BC和CC所有這些#包括COMMON.HGCC編譯時類型解析
在COMMON.H,我包括「SYS/socket.h中」和我的護COMMON.H由宏:
#ifndef __COMMON_H
#define __COMMON_H
// body of file goes here
#endif
當我編譯的代碼,我得到一些錯誤,如下面
In file included from /usr/include/sys/socket.h:40,
from tcpperf.h:4,
from wrapunix.c:1:
/usr/include/bits/socket.h:425: error: conflicting types for 'recvmmsg'
/usr/include/bits/socket.h:425: note: previous declaration of 'recvmmsg' was here
In file included from /usr/include/sys/socket.h:40,
from tcpperf.h:4,
from wrapsock.c:1:
正如你可以看到wrapunix.c和wrapsock.c,它們都包括tcpperf。 h,但tcpperf.h是用宏來保護的,但是gcc抱怨說recvmsg被多次聲明。我該如何解決這個問題?
更新: 這裏是tcpperf.h的報頭,也就是造成問題
#ifndef _TCPPERF_H
#define _TCPPERF_H
#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>
#include <regex.h>
#include <errno.h>
#include <sched.h>
#include <pthread.h>
#include <argp.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <linux/tcp.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <sys/wait.h>
#endif
上述錯誤可以通過提供「-combine -fwhole程序」的標誌與gcc如
再現gcc -std = gnu99 -Wall -combine -fwhole-program -I。 error.c wrapunix.c wrapsock.c file1.c file2.c -o file2 -lrt
檢查循環依賴關係;如果我沒有記錯,兩個包含對方的標題可能會導致這種情況。 – 2012-12-17 23:01:48
顯示您的代碼。 – melpomene
帶有兩個前導下劃線或帶有一個前導下劃線和大寫字母的標識符被保留供語言實現使用。 –