#undef UNICODE
#define UNICODE
#include <windows.h>
void startup()
{
MessageBox( 0, L"Click the OK button, please.", L"Hi!", MB_SETFOREGROUND );
ExitProcess( 0 );
}
[C:\my\forums\so\279]
> cl minimal.cpp /link /nodefaultlib /entry:startup /subsystem:console kernel32.lib user32.lib
minimal.cpp
[C:\my\forums\so\279]
> dir
Volume in drive C is OS
Volume Serial Number is 58BC-07CA
Directory of C:\my\forums\so\279
28.01.2017 21:43 <DIR> .
28.01.2017 21:43 <DIR> ..
28.01.2017 21:43 215 minimal.cpp
28.01.2017 21:43 2 560 minimal.exe
28.01.2017 21:43 860 minimal.obj
3 File(s) 3 635 bytes
2 Dir(s) 274 278 531 072 bytes free
[C:\my\forums\so\279]
> _
cl
is the Visual C++ compiler. My default options (via the CL
environment variable) are /nologo /EHsc /GR /W4 /FI "iso646.h"
, but I believe only the exception handling option affects anything here, if it all. The user32.lib
library is linked because I used the MessageBox
function.
Do note that the runtime library takes care of parts of the C++ core language infra-structure. That includes dynamic initialization of namespace scope variables, and depending on the compiler it might include some of the support for exceptions. I don't know the details about Visual C++ in this regard, but it's necessary to be very, very careful: one is operating in a regime where the basic assumptions of the tools, don't hold.