|
|
|
#1 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
C++ Question
I am using Dev-C++ and wondering why
(I removed the pointed brackets from the header names because the browser mistakes it for HTML) Code:
#include stdio.h
int main()
{
printf("hello world");
return 0;
}
Code:
#include iostream.h
int main()
{
cout <<"hello world";
return 0;
}
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 |
|
|
|
|
|
#2 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Feb 2002
Location: Where ever fate shall lead me.
Posts: 3,946
|
Re: C++ Question
Is code 1 (C)
whereas code 2 is (C++). Im just curios. Since im pretty sure Code 2 is C++. But i haven't seen code 1 before, but the structure is the same, so i just though it might be C |
|
|
|
|
|
#3 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
Re: C++ Question
Yes, but why should the second one be 420K in size? Why does using iostream.h increase the filesize by ~400K?
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 Last edited by scott_uk5; August 3rd, 2003 at 18:31. |
|
|
|
|
|
#4 (permalink) |
|
Puchiko-nyu!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2001
Location: 49° 11' N 123° 10' W
Posts: 2,854
|
Re: C++ Question
The C++ iostream library encapsulates the stream manipulations into 2 basic classes (cin and cout). It abstracts a LOT of the nitty-gritty details (especially in file manipulations) that otherwise you have to deal with when using the C stdio library. With all these abstractions and encapsulation, your life is easier when doing I/O, however, as a tradeoff the compiled filesize is bigger.
__________________
"Not every ejaculation deserves a name." --- George Carlin |
|
|
|
|
|
#5 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
Re: C++ Question
But that same program compiled with MetroWerks Codewarrier 6 is only 72K
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 |
|
|
|
|
|
#6 (permalink) |
|
Puchiko-nyu!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jul 2001
Location: 49° 11' N 123° 10' W
Posts: 2,854
|
Re: C++ Question
Now that goes beyond my knowledge. It's different compiler behaviours. Different compilers treat and compile different code differently. There may be some optimization flags you can set here and there to tweak the code size. Check the documentation of the compiler(s) you're using to see what types of optimization flags you can use to reduce binary size or do a processor specific optimization, etc.
__________________
"Not every ejaculation deserves a name." --- George Carlin |
|
|
|
|
|
#7 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
Re: C++ Question
Dev-C++ uses Mingw. By adding -s argument to the linker and running the EXE through UPX, I was able to get the filesize down to 72K.
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 |
|
|
|
|
|
#9 (permalink) |
|
Registered User
![]() ![]() ![]() ![]() ![]() Join Date: Sep 2002
Location: St Andrews, Scotland
Posts: 1,575
|
Re: C++ Question
It's open source. That's what the ePSXe team use to compress their EXEs.
http://upx.sourceforge.net/
__________________
OS: Arch Linux w/ Kernel 2.6.23.8 + GNOME 2.20.1 - CPU: Intel Pentium M 1.5GHz - Memory: 1280MB DDR PC2700 - Browser: Mozilla Firefox 2.0.0.10 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|