winsamp.d and -O
Andrej Mitrovic
andrej.mitrovich at gmail.com
Tue Jun 14 15:09:17 PDT 2011
To make the example compile with optimizations, you have to trick the
compiler so it can't determine whether it's a null dereference at
compile-time. Change the code to this:
int* p;
extern (Windows)
int WindowProc(HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_BTNCLICK:
if (HIWORD(wParam) == BN_CLICKED)
MessageBoxA(hWnd, "Hello, world!", "Greeting",
MB_OK | MB_ICONINFORMATION);
break;
case IDC_BTNDONTCLICK:
if (HIWORD(wParam) == BN_CLICKED)
{
MessageBoxA(hWnd, "You've been warned...",
"Prepare to GP fault",
MB_OK | MB_ICONEXCLAMATION);
*p = 1;
}
... more code ...
And then it will compile and throw at runtime when u press the dontclick button.
More information about the Digitalmars-d
mailing list