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

;Includes
	;External
	Include	\masm32\include\windows.inc
	Include	\masm32\include\user32.inc
	Include	\masm32\include\kernel32.inc
	Include \masm32\include\gdi32.inc
	IncludeLib \masm32\lib\kernel32.lib
	IncludeLib \masm32\lib\user32.lib
	IncludeLib \masm32\lib\gdi32.lib
	;Internal
	Include Logs.inc

;Procedures
	WinMain Proto :DWord, :DWord, :DWord, :DWord

.Const

.Data?
	hInstance HINSTANCE ?
	CommandLine LPSTR ? 

.Data
	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!!!
Posted
Updated 8-May-10 5:54am
v2

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.

CRITICAL_SECTION STRUCT 
          DebugInfo      DWORD ? 
          LockCount      LONG ? 
          RecursionCount LONG ? 
          OwningThread   HANDLE ? 
          LockSemaphore  HANDLE ? 
          SpinCount      DWORD ? 
CRITICAL_SECTION ENDS

; 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 (< ? >)


Alan.
 
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