【发布时间】:2015-06-23 16:15:40
【问题描述】:
我刚刚开始将 C 作为一种爱好来学习。我正在使用“C 编程:一种现代方法”一书来做这件事。那里有一个名为pun.c 的第一个程序。代码如下:
#include <stdio.h>
int main(void)
{
int int_figure;
float float_figure;
int_figure = 12;
float_figure = 12.0;
printf("To C or not to C, this is a question\n");
printf("%d\n", int_figure);
printf("%.2f\n", float_figure);
return 0;
}
其实没关系,因为我想问的问题与gcc的任何.c文件编译都是一样的。
所以在书中有一些gcc 的选项允许在编译期间发现错误。其中一个是-Wall,另一个是-pedantic。因此,当我使用此选项编译文件时,终端中的输出如下:
nickdudaev|c $ gcc -o -Wall pun pun.c
pun: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/crti.o:(.fini+0x0): first defined here
pun: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/crt1.o:(.data+0x0): first defined here
pun: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/crtbegin.o:(.data+0x0): first defined here
pun:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
pun: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/crt1.o:(.text+0x0): first defined here
pun: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/../../../../lib/crti.o:(.init+0x0): first defined here
/tmp/cc2TRR93.o: In function `main':
pun.c:(.text+0x0): multiple definition of `main'
pun:(.text+0xf6): first defined here
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
pun:(.data+0x10): first defined here
/usr/bin/ld: error in pun(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
程序虽然运行正常。
nickdudaev|c $ ./pun
To C or not to C, this is a question
12
12.00
所以问题。
- 在这个(学习)阶段我应该担心这个输出并使用这些选项吗?
- 我可能有一些系统错误吗?因为任何文件编译的输出都是相同的。可能没有正确安装?
我试图搜索 Google,但我发现的唯一内容是关于 gcc 选项的描述。但没有关于可能的输出以及如何处理它。
【问题讨论】:
标签: c gcc compiler-errors compiler-warnings compiler-options