D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4341 - compiling with -unittest on win32 produces invalid executable
Summary: compiling with -unittest on win32 produces invalid executable
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-17 07:49 UTC by Michal Minich
Modified: 2011-07-09 23:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michal Minich 2010-06-17 07:49:05 UTC
when the "-unittest" switch is not included, applications is compiled. With unittest enabled, after running the resulting exe I receive "... is not valid Win32 application".

dmd: 2.047
command line: "dmd -unittest hello.d hello.def" 

file are:

hello.def:
EXETYPE NT
SUBSYSTEM WINDOWS


hello.d: (example from digitalmars website)
module hello;

import core.runtime;
import std.c.windows.windows;

extern (Windows)
int WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
    int result;

    void exceptionHandler(Throwable e)
    {
	throw e;
    }

    try
    {	
	Runtime.initialize(&exceptionHandler);

	result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);

	Runtime.terminate(&exceptionHandler);
    }

    catch (Object o)		// catch any uncaught exceptions
    {
	MessageBoxA(null, cast(char *)o.toString(), "Error",
		    MB_OK | MB_ICONEXCLAMATION);
	result = 0;		// failed
    }

    return result;
}

int myWinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
   return 1;
}


unittest {

assert (1 == 1, "aa");
}
Comment 1 Adrian Matoga 2010-08-11 04:51:01 UTC
Seems like it's fixed in 2.048. Compiles and runs correctly with and without unittests.
Comment 2 yebblies 2011-07-09 23:26:16 UTC
According to the above comment, this has been working since 2.048