Code :: Blocks 8.02
Ubuntu 10.04 LTS (x86_64)
I write Sishny code. The compiler swears that there is no g ++ and asks to install. Installed. It worked. Now the question is, what is the difference between compiled C code in gcc and C code in g ++?
Why does IDE require a C ++ compiler for C code?
Everything is very simple. G ++ is used as a linker (linker):
gcc -Wall -O2 -c /home/gaal/TEST/TEST/main.c -o obj/Release/main.o g++ -o bin/Release/TEST obj/Release/main.o -s Now the question is, what is the difference between compiled C code in gcc and C code in g ++?
See comments to the previous answer . If the compiler is gcc and the linker is g ++, then dependencies on the C ++ libraries will be added. If the compiler and linker are g ++ with keys for C code, then again there will be certain libraries. But in theory, the code will be "Sishny."
The C ++ runtime will be stitched into the binary, perhaps some additional sections will be added.
There will be other library dependencies:
C :
linux-vdso.so.1 => (0x00007fff6ab46000) libc.so.6 => /lib/libc.so.6 (0x00007f0eb1149000) /lib64/ld-linux-x86-64.so.2 (0x00007f0eb14f4000) C++ :
linux-vdso.so.1 => (0x00007fff12fff000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fe1cab00000) libm.so.6 => /lib/libm.so.6 (0x00007fe1ca87d000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fe1ca666000) libc.so.6 => /lib/libc.so.6 (0x00007fe1ca2e3000) /lib64/ld-linux-x86-64.so.2 (0x00007fe1cae2e000) Here is the code:
int main(){} compiled ( gcc , g++ ) and disassembled differed only in strings:
// в начале main .cfi_personality 0x3,__gxx_personality_v0 ... // при выходе из main movl $0, %eax In the C ++ version both were added. The first line - apparently, some metadata, but I can not explain the second, but in general, nothing substantial. For some reason, the eax register is reset.
movl $0 not. - Vladimir GordeevSource: https://ru.stackoverflow.com/questions/7405/
All Articles