What is wrong with this boilerplate mixin?

Max Samuha maxter at i.com.ua
Mon Oct 23 00:18:10 PDT 2006


On Mon, 23 Oct 2006 05:56:08 +0000 (UTC), AF <noemail at noemail.com>
wrote:

>Hello,
>
> To make Win programming simpler, I divided sample application
>(winsample.d) in a standard module (modwin.d) containing the
>boilerplate code, and a application (appwin.d) file.
> Both files resides in the same directory.
> However, it does not link:
>
> D:\temp\dlang5>dmd appwin.d
>c:\dmd\bin\..\..\dm\bin\link.exe appwin,,,user32+kernel32/noi;
>OPTLINK (R) for Win32  Release 7.50B1
>Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
>
>c:\dm\bin\..\lib\SNN.lib(winstart)
> Error 42: Symbol Undefined _WinMain at 16
>
> So, what to do? And, 2nd, could things be made simpler? Attached
>are modwin.d and appwin.d.

The mixed-in WinMain is mangled like
__D6appwin11__T6WinAppZ7WinMainWT3std1c7windows7windows6HANDLET3std1c7windows7windows6HANDLEPaiZi at 16
instead of _WinMain at 16. This might be because the compiler doesn't
handle extern(Windows) properly in the template. You could declare a
global delegate in modwin which will be called in WinMain (instead of
directly calling your myWinMain) and attach myWinMain to it in the
static constructor of appwin. Or you could use DFL or other
application framework.  



More information about the Digitalmars-d-learn mailing list