0

I'm following Iczelion's Win32 tutorials, specifically tutorial 3 ("A Simple Window"), and when trying to "strip out" some of the error handling and unnecessary code for the sake of experimentation, I get the following error when compiling:

test.asm(38) : error A2111: conflicting parameter definition.

Here is the line:

Line 38:

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:DWORD

My question is: What is wrong with this line of code?

Thanks in advance.

EDIT:

Here is the entire script, with the offending line commented in:

.386 

.model flat, stdcall 
option casemap :none 

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc 
include \masm32\include\user32.inc 
include \masm32\include\kernel32.inc 
include \masm32\include\gdi32.inc 
includelib \masm32\lib\user32.lib 
includelib \masm32\lib\kernel32.lib 
includelib \masm32\lib\gdi32.lib

.data 

    ClassName db "Testwin", 0
    AppName db "Testing Window", 0

.data?

    hInstance HINSTANCE ?

.code 
start: 

    push NULL
    call GetModuleHandle
        mov  hInstance,eax
    push SW_SHOWDEFAULT
    push NULL
    push hInstance
    call WinMain
    push eax
        call ExitProcess

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:DWORD   ; this is the line
; local vars:
LOCAL wc:WNDCLASSEX 
    LOCAL msg:MSG 
    LOCAL hwnd:HWND

; defining the window:
    mov   wc.cbSize,SIZEOF WNDCLASSEX 
    mov   wc.style, CS_HREDRAW or CS_VREDRAW 
    mov   wc.lpfnWndProc, OFFSET WndProc 
    mov   wc.cbClsExtra,NULL 
    mov   wc.cbWndExtra,NULL 
    push  hInst 
    pop   wc.hInstance 
    mov   wc.hbrBackground,COLOR_WINDOW+1 
    mov   wc.lpszMenuName,NULL 
    mov   wc.lpszClassName,OFFSET ClassName 
    invoke LoadIcon,NULL,IDI_APPLICATION 
    mov   wc.hIcon,eax 
    mov   wc.hIconSm,eax 
    invoke LoadCursor,NULL,IDC_ARROW 
    mov   wc.hCursor,eax 
    invoke RegisterClassEx, addr wc 
;create the window
    invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\ 
           WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\ 
           CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\ 
           hInst,NULL
    invoke ShowWindow,hwnd,CmdShow
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM   
    cmp uMsg, WM_DESTROY
    jne _next
    invoke PostQuitMessage, NULL
_next:

WndProc endp      
end start    

Hope this helps.

Raymond Chen
  • 44,448
  • 11
  • 96
  • 135
Progrmr
  • 1,575
  • 4
  • 26
  • 44
  • 2
    I suspect the errors actually start with something you've stripped out before line 38. How do you know it's unnecessary? I also recommend posting _all_ the code up through line 75 at least. – Rob I Aug 30 '12 at 04:17
  • Edited comment to show extra code. Sorry – Progrmr Aug 30 '12 at 04:32
  • In the Iczelion tutorial, he says that they are extra "unnecessary" error handling loops, etc. By unnecessary he means they are not vital to the program compiling. – Progrmr Aug 30 '12 at 04:38
  • I just noticed that on line 69 I had double-defined `WndProc`, this fixes the second two errors. I have edited them out. – Progrmr Aug 30 '12 at 04:40

1 Answers1

5

The three error messages explain exactly what you did wrong.

test.asm(38) : error A2111: conflicting parameter definition.

Look at your prototype again:

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:DWORD

The parameters to WinMain conflict with a previous declaration. If you look at the earlier declaration, you'll see that the parameter lists are different.

The next error:

test.asm(69) : error A2008: syntax error: WndProc

Let's look at that line:

WndProc WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

Syntax error means that you violated the grammar. In this case, it's because the assembler couldn't figure out what to do with the second WndProc; repeating WndProc is not legal here.

Third error:

test.asm(75) : fatal error A1010: unmatched block nesting: WndProc

Since the WndProc procedure never got properly started, your attempt to end it was invalid.

TL;DR: Read the error messages. They will explain what you did wrong.

Raymond Chen
  • 44,448
  • 11
  • 96
  • 135