Ananth A <writetoananth at gmail.com> writes: >> Yeah C++ compilation is always slower due to overheads. Have you tried >> adding extern "C" for you hello world program to force C linkage and >> disable the C++ poly-mangled-virtual-inherited-temporarily-constructed- >> referential overheads ? I dunno whether this will help though. :-P > > not just compiling but execution speed ( as per wall clock) is also slower. > > most of the overheads were disabled using the cmd line options to g++...
As I understand it, the difference is what you link with unless you are compiling c++ code. I have this snippet in x.c: int main() { int i; i = 1; return (0); } $ gcc -c x.c $ g++ -o xCC -c x.c $ gcc -o x_c x.c $ g++ -o x_cc x.c ------- at ---- tmp> ls -l x* -rw-r--r-- 1 ------- staff 46 Apr 7 23:04 x.c -rw-r--r-- 1 ------- staff 630 Apr 7 23:06 x.o -rw-r--r-- 1 ------- staff 630 Apr 7 23:06 xCC.o -rwxr-xr-x 1 ------- staff 6004 Apr 7 23:04 x_c -rwxr-xr-x 1 ------- staff 6108 Apr 7 23:05 x_cc $ diff x.o xCC.o $ diff x_c x_cc Binary files x_c and x_cc differ Needless to say startup is where the speed difference must be. cheers Binu