我有幾個問題需要編譯一個C程序來將聲音從Intel Edison傳輸到設備(iOS和Android)。在幾個頭文件中重新定義'struct timeval'
我做了一個C程序: 我在我的程序中使用alsa/asoundlib.h和pthread.h我沒有包含sys/time.h,因爲ALSA不允許這樣做。
我用很多的timeval在我的程序,當我編譯它在我的電腦上i'ts編譯好的,但在我的愛迪生當我:
gcc -std=c99 -Wall -O0 -ggdb -o sender sender.c spsc_circular_queue.c -lopus -lasound -lpthread
In file included from /usr/include/alsa/asoundlib.h:49:0,
from sender.c:16:
/usr/include/alsa/global.h:145:8: error: redefinition of 'struct timespec'
struct timespec {
^
In file included from /usr/include/alsa/global.h:34:0,
from /usr/include/alsa/asoundlib.h:49,
from sender.c:16:
/usr/include/time.h:120:8: note: originally defined here
struct timespec
^
In file included from /usr/include/time.h:41:0,
from /usr/include/sched.h:34,
from sender.c:18:
/usr/include/bits/time.h:30:8: error: redefinition of 'struct timeval'
struct timeval
^
In file included from /usr/include/alsa/asoundlib.h:49:0,
from sender.c:16:
/usr/include/alsa/global.h:140:8: note: originally defined here
struct timeval {
^
Makefile:16: recipe for target 'sender' failed
make: *** [sender] Error 1
如何管理,制止這些redifinitions?! 謝謝你的幫助!
額外的信息:
我包括:
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <alloca.h>
#include <limits.h>
#include <inttypes.h>
#include <alsa/asoundlib.h>
#include "../opus/include/opus.h"
#include <pthread.h>
#include "spsc_circular_queue.h"
我刪除sched.h中,沒有發生
您在第18行的sender.c中包含'/ usr/include/sched.h',其中包含'/ usr/include/time.h'。 – mch
更改內容不包括: – maathor
您已經做過##包括',它包含'#include '。那就是問題所在。如果你刪除了'#include ',錯誤信息將會改變,以引導你到下一個問題。 –
mch