www.digitalmars.com         C & C++   DMDScript  

c++ - 367KB For Hello World !!

reply "Yeric" <REMOVEamigabloke yahoo.co.ukREMOVE> writes:
Ok I am sure someone is going to be able to tell me that there is something
else I can do here to reduce the size from 367KB.

I compiled dmc hello -o+space & dmc hello -o

both file sizes were almost the same, the -o+space was slightly higher by a
few bytes.

I know in GCC you can pass -s to the linker to strip symbols to reduce the
exe, is there something similar in dmc or is 367KB the best I can hope for
in a 5 line console ??

I am not overly bothered size isnt everything <g> as I discovered a slightly
larger program 10 lines does not increase excessivley over the 367KB

Any ideas please ?
Jul 29 2003
parent reply "Greg Peet" <admin gregpeet.com> writes:
"Yeric" <REMOVEamigabloke yahoo.co.ukREMOVE> wrote in message
news:bg6lka$2e0g$1 digitaldaemon.com...
 I compiled dmc hello -o+space & dmc hello -o
You have a file called "hello" containing the source? Are you using the C runtime or C++ iostream for output? If it's C++, you have your answer...the implementation. I still have not found a mildly-sized C++ iostream. Use printf instead.
Jul 29 2003
next sibling parent reply "Greg Peet" <admin gregpeet.com> writes:
I wrote a hello world with printf and then with iostream, using stlport and
dmc 8.35:

printf:  38 KB
cout:   366 KB

You can try the printf/cout test with most compilers, and I guarantee that
you will mostly get higher footprints for the iostream use. Bjarne
Stroustrup says (in The C++ Programming Language), that this is a
misconception and it's all based on your library provider. Well, I've used a
lot of different compilers/libraries and always have seen the same thing.
Think about printf/scanf over the cout/cin family.
-- 

Regards,
Gregory Peet

Fellow Digital Martian
STLSoft FAQ: http://stlsoft.gregpeet.com
Jul 29 2003
next sibling parent reply Ilya Minkov <midiclub 8ung.at> writes:
Greg Peet wrote:
 I wrote a hello world with printf and then with iostream, using 
stlport and
 dmc 8.35:

 printf:  38 KB
 cout:   366 KB
Oh c'mon! I used the STL included with DMC. dmc hello.cpp -Nc -6 -o With my stubborn Hello program, result: .exe 48156 bytes .obj 829 bytes With a standard hello world: .exe 47132 bytes .obj 376 bytes Stubborn Hello Source: --- 8< --- #include <iostream.h> int main (int argc, char *argv[]) { char quit = '\0'; while (quit != 'q') { cout << "Hello ! This is a very simple but stubborn console app." << endl; cout << "\tPress q to quit " << endl; cin >> quit; } return 0; } --- >8 --- -i.
Jul 29 2003
parent "Greg Peet" <admin gregpeet.com> writes:
Are you using the default SGI Library or STLPort?

"Ilya Minkov" <midiclub 8ung.at> wrote in message
news:bg6upt$2n5b$1 digitaldaemon.com...
 Greg Peet wrote:
  > I wrote a hello world with printf and then with iostream, using
 stlport and
  > dmc 8.35:
  >
  > printf:  38 KB
  > cout:   366 KB

 Oh c'mon!
 I used the STL included with DMC.

 dmc hello.cpp -Nc -6 -o

 With my stubborn Hello program, result:

 .exe 48156 bytes
 .obj 829 bytes

 With a standard hello world:
 .exe 47132 bytes
 .obj 376 bytes


 Stubborn Hello Source:
 --- 8< ---

 #include <iostream.h>

 int main (int argc, char *argv[]) {
      char quit = '\0';

      while (quit != 'q')     {
          cout << "Hello ! This is a very simple but stubborn console
 app." << endl;
          cout << "\tPress q to quit " << endl;
          cin >> quit;
      }

      return 0;
 }

 --- >8 ---

 -i.
Jul 29 2003
prev sibling parent reply "Yeric" <REMOVEamigabloke yahoo.co.ukREMOVE> writes:
 I wrote a hello world with printf and then with iostream, using stlport
and
 dmc 8.35:

 printf:  38 KB
 cout:   366 KB

 You can try the printf/cout test with most compilers, and I guarantee that
 you will mostly get higher footprints for the iostream use. Bjarne
 Stroustrup says (in The C++ Programming Language), that this is a
 misconception and it's all based on your library provider. Well, I've used
a
 lot of different compilers/libraries and always have seen the same thing.
 Think about printf/scanf over the cout/cin family.
 -- 

 Regards,
 Gregory Peet

 Fellow Digital Martian
Indeed I a also using the STLPort library thanks for taking the time to check it out. Like I say I am not to bothered, as larger programs do not grow exponentially only very small increments Thanks Yeric A new Digital Martian <g>
Jul 30 2003
parent reply "Yeric" <REMOVEamigabloke yahoo.co.ukREMOVE> writes:
Hmmm

Much fiddling later in IDDE and I have managed to get exe to 18kb

How?

In project settings set use dll runtime library ans et voilla 18kb
however if you use the system ( "PAUSE" ) ; in program it crashes ouch
but if you use cin >> some int ; it doesn't, anyone know what causes this
???

cheers
Yeric
Aug 12 2003
parent reply Ilya Minkov <midiclub 8ung.at> writes:
Yeric wrote:
 Hmmm
mmmmH
 Much fiddling later in IDDE and I have managed to get exe to 18kb
So you use IDDE. Command-line rules!
 In project settings set use dll runtime library ans et voilla 18kb
 however if you use the system ( "PAUSE" ) ; in program it crashes ouch
 but if you use cin >> some int ; it doesn't, anyone know what causes this
 ???
Walter already said the DLL RTL support was broken. I was considering to make the compiler use Microsoft DLL RTL which is delivered with Windows - because it is the only way to make the compiler qualify for 64k-demos. If not RTL issue, DigitalMars would be the best compiler for such things around! -i.
Aug 12 2003
parent Yeric < REMOVE AmigaBloke yahoo.co.uk REMOVE> writes:
<g> yes, I could get prog to compile in about 18kb with command line before,
but wanted to use the idde, well if you got it use it, I say <g>



 Walter already said the DLL RTL support was broken.
Sorry I missed that one dute
 I was considering to make the compiler use Microsoft DLL RTL which is
 delivered with Windows - because it is the only way to make the compiler
 qualify for 64k-demos. If not RTL issue, DigitalMars would be the best
 compiler for such things around!
 
 -i.
googled for this bit about rtl dll broken, could not find owt on it though, is it planned to be fixed in th future ? Yeric
Aug 13 2003
prev sibling parent "Yeric" <REMOVEamigabloke yahoo.co.ukREMOVE> writes:
 You have a file called "hello" containing the source? Are you using the C
Nope you are correct iostream in C++
 If it's C++, you have your answer...the implementation. I still have not
 found a mildly-sized C++ iostream. Use printf instead.
Ok thanks
Jul 30 2003