Mail Archives: djgpp/1998/03/04/16:46:07
Interesting!
AFAIK, djgpp is a good optimizing compiler, but there may be something funny happening with your in-loop declarations. (Although my guess is that gxx is gcc with different libraries.) The program may have to continuously reallocate the heap (if that's the precise term). I suggest trying the identical code in C and C++, so you're comparing apples and apples.
> > > The test code is quite simple, consisted of 3 nested "for" loops.
> >
>
> Let me first thank you for your kind concern.
>
> Main body of my test code is
>
> for(int i=1 ; i<10001 ; i++)
> for(int j=1 ; j<10001 ; j++)
> for(int k=1 ; k < 11 ; k++) sum += i;
>
> Above code is ,of course , for C++.
>
> In C code, I just moved variable definitions
> into the first line of the code.
> Like,
>
> int i,j,k;
> float sum;
>
> That's all.
>
> I don't think that makes musch difference between C++ and C.
>
> And compile option is ,
>
> C code : gcc -O2 -o testc.exe testc.c
> C++ code : gxx -O2 -o testcpp.exe testcpp.cpp
>
> And I'm using DJGPP v.2.10
>
> Did I make some mistakes or misunderstand something important?
>
> Anyway, thank you and wish you goooooooooooooooooooood Luck !!!!
>
> Bum-Seok Hyun
> mailto:dominic AT gong DOT snu DOT ac DOT kr
- Raw text -