Click here to Skip to main content
15,795,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've tried to declare a critical section in ASM but have some problems. Below is my code:
.Model flat, StdCall
Option CaseMap:none

	Include	\masm32\include\
	Include	\masm32\include\
	Include	\masm32\include\
	Include \masm32\include\
	IncludeLib \masm32\lib\kernel32.lib
	IncludeLib \masm32\lib\user32.lib
	IncludeLib \masm32\lib\gdi32.lib

	WinMain Proto :DWord, :DWord, :DWord, :DWord


	hInstance HINSTANCE ?
	CommandLine LPSTR ? 

	WndCritical CRITICAL_SECTION dup(0)
	AppTitle DB "[VeMU]ConnectServer", 0
	ClassName DB "ClassName", 0

And here are the errors:
(27)error A2179: structure improperly initialized
(27)error A2008: syntax error: dup
The line 27 is: WndCritical CRITICAL_SECTION dup(0)

How to make it properly? Thanks in advance!!!
Updated 8-May-10 6:54am

1 solution

It's a while since I did this but surely DUP is used to declare arrays. It's angle brackets for structure initialisation.

          DebugInfo      DWORD ? 
          LockCount      LONG ? 
          RecursionCount LONG ? 
          OwningThread   HANDLE ? 
          LockSemaphore  HANDLE ? 
          SpinCount      DWORD ? 

; explicit initialisation of all fields
WndCritical1 CRITICAL_SECTION <0, 0, 0, 0, 0, 0>
; use default values
WndCritical2 CRITICAL_SECTION < ? >
; array of 8 critical sections
WndCriticalArray CRITICAL_SECTION 8 DUP (< ? >)

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900