www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Minimal D executable on Windows x32

reply "RivenTheMage" <riven-mage id.ru> writes:
Did it just for fun, maybe it will help someone :)

Requires UniLink:
ftp://ftp.styx.cabel.net/pub/UniLink


main.d
--------
extern(C)
void _acrtused_con()
{
	mainFunc();
}

extern(Windows)
{
	int MessageBoxA(uint hWnd, char* lpText, char* lpCaption, uint
uType);
	void ExitProcess(uint uExitCode);
}

void mainFunc()
{
	MessageBoxA(0, cast(char*) "Hello, World!".ptr, cast(char*)
"Nano-D".ptr, 0);
	ExitProcess(0);
}
--------


object.d
--------
module object;

struct ModuleInfo
{
	// nothing
}
--------


Compiling: dmd -c main.d
Linking: ulink.exe -e__acrtused_con
-L{YOUR_PATH_TO_DMD}\windows\lib -zkernel32;user32 main.obj


Size of main.exe is 1068 bytes.
Feb 12 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
RivenTheMage:

 Size of main.exe is 1068 bytes.
I have tried it, and it works :-) Seems useful using the -betterC switch discussed in the main D newsgroup. Bye, bearophile
Feb 12 2014