"Alf P. Steinbach" <alfps@start.no>
Using Visual C++ 2010, creating native x86 code in default release
settings (i.e. no fancy optimization tricks), a C++ program printing
"hello world" to a console window is 8k.
No doubt it can be reduced to that.
It is not "can be reduded" but it *is* 8k. I really miss your point of
this thread.
In fact I have no trouble reducing it to 4 KiB in Windows (and less if
I ain't afraid of letting the loader fix up things, but there's a 4
KiB pagesize), and in *nix it can be just a few hundred bytes IIRC.
Which doesn't say anything, really -- I was talking about typical size.
Typical supposed to mean tweaked specially to show increase?
<example>
C:\test> cedit x.cpp
C:\test> msvc --version
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
C:\test> msvc x.cpp
x.cpp
C:\test> dir | find "x.exe"
21.04.2010 16:43 73 728 x.exe
C:\test> type x.cpp
#include <iostream>
int main(){ std::cout << "Hello, world!" << std::endl; }
Dunno what you do. I launched Visual Studio 2008(SP1), create new
project for WIN32 console, then copy in your code ( by myself I'd
certainly used puts, streams is pure overhead...):
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{ std::cout << "Hello, world!" << std::endl; }
switch taregt to Release, and the resulting exe has size 9216. Not
anywhere near 73k. Sure it is still quite fat, dumpbin reveals that it
has a manifest, a bunch of locking in streambuf, security cookies, etc.
Note: I don't know the answer to the that question. With the examples I
presented the programs could be copied freely, with the stated sizes. I suspect
that your Visual Studio default-settings program may be larger than you think...