I have just started to learn C as a hobby. I am doing it with the "C programming: A Modern Approach" book. There is a first program there which is called pun.c. Here is the code:
#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;
}
Actually it does not matter because the thing I want to ask about is the same with any .c file compilation with gcc.
So in the book there are some options for gcc which allow finding errors during compilation.One of them is -Wall, another one is -pedantic. So when I compile the file with this option, the output in terminal is the following:
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
The program although runs correctly.
nickdudaev|c $ ./pun
To C or not to C, this is a question
12
12.00
So to the questions.
- Should I on this stage (of learning) worry about this output and at all use those options?
- Do I have probably some systematic error? Because output is the same for any file compilation. Maybe something is not properly installed?
I tried to search Google, but the only thing I found is descriptions of what gcc options do. But nothing about possible output and what to do with it.
This:
doesn't look right. You're saying
-Wallwhere you should say the name of the output, i.e. the argument to-o.Try:
Basically you're feeding
pun, the old binary, to gcc as a source file.