0
我不知道爲什麼我收到這些錯誤,當我編譯GCC
並且不使用-Wall
和-Wextra
程序編譯得很好。但是,當我使用標誌-Wall
和-Wextra
時,我收到編譯錯誤。在GCC中使用-Wall -Wextra並出現錯誤
下面是測試程序,我跑:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void)
{
return 0;
}
...這是錯誤,我從獲得:
/home/definity/Desktop/Cloud/code/funcptr: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
/home/definity/Desktop/Cloud/code/funcptr: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here
/home/definity/Desktop/Cloud/code/funcptr: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o:(.data+0x0): first defined here
/home/definity/Desktop/Cloud/code/funcptr:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
/home/definity/Desktop/Cloud/code/funcptr: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here
/home/definity/Desktop/Cloud/code/funcptr: In function `main':
/home/definity/Desktop/Cloud/code/funcptr.c:35: multiple definition of `main'
/tmp/cctHUnUj.o:/home/definity/Desktop/Cloud/code/funcptr.c:9: first defined here
/home/definity/Desktop/Cloud/code/funcptr: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
/home/definity/Desktop/Cloud/code/funcptr:(.data+0x10): first defined here
/usr/bin/ld: error in /home/definity/Desktop/Cloud/code/funcptr(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
[Finished in 0.1s with exit code 1]
......我無法解釋這些錯誤。有人可以解釋爲什麼會發生這些錯誤,我可以做些什麼來防止這種情況在將來發生?
是編譯成功沒有'-Wall -Wextra'?我敢肯定,他們不會將任何警告轉化爲錯誤,所以我想知道如果沒有它們,它會起作用。你可能會搞砸GCC安裝。 –
你改變了這個問題嗎? –
我試試你的代碼和'gcc -Wall -Wextra'它。它只是編譯好! –