C++ compiling really slow


Forum: Programming and Scripting
Topic: C++ compiling really slow
started by: eedok

Posted by eedok on Mar. 01 2006,06:59
when I compile hello world in C++ it takes like 12 seconds to compile
Code Sample

#include <iostream>
int main(){
std::cout << "Hello World!" << std::endl;
}

but when I program hello world in C it finishes in under a second
Code Sample

#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
}



Why does the C++ version take so long to compile? Any ways to speed it up?
this is using the gcc1.dsl package

Posted by cbagger01 on Mar. 01 2006,07:10
Maybe enable DMA for your hard drive. You can boot with:

dsl dma

to try this.

Posted by eedok on Mar. 02 2006,05:27
there's no hard drive and I don't see how hard drive speed will change this as it's less than 1KB of a file.
Posted by _pathos on Mar. 02 2006,07:00
C++ is just a lot more complicated.

The compiler has to do a lot of work processing the files included directly/indirectly by iostream:

#include <istream>
#include <ostream>
#include <ios>
#include <iosfwd>
#include <exception>
#include <bits/char_traits.h>
#include <cstdio>                   <---- even the stdio C header file
#include <bits/localefwd.h>
#include <bits/ios_base.h>
#include <streambuf>
#include <bits/basic_ios.h>

Linking the C std functions is a piece of cake. stdio includes only one or two basic files.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.