flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > BUG: Macro Processing Error?
Author
kidscracker

Joined: 29 Oct 2004
Posts: 46
Location: Peru
kidscracker
Well I've been learning the macro sintaxis for the last 2 weeks, and can't find a workaround for this problem. I define a constant with a value, depending the value of this constant I define some macros in my include files, here is the code:
Code:
```format PE GUI 4.0
entry start

UNICODE EQU     TRUE

include '%fasminc%164\win32w.inc'
```

The win32w.inc is:
Code:
```; Win32 programming headers (WideChar)
include 'macro/struct.inc'
include 'macro/proc32.inc'
include 'macro/com32.inc'
include 'macro/import32.inc'
include 'macro/export.inc'
include 'macro/resource.inc'

struc CHAR val { match any, val \{ . du val \}
match , val \{ . du ? \} }

include 'equates/kernel32.inc'
include 'equates/user32.inc'
include 'equates/gdi32.inc'
include 'equates/comctl32.inc'     ;<--- My modified include
include 'equates/comdlg32.inc'
include 'equates/shell32.inc'
include 'equates/wsock32.inc'
```

at the top of the comctl32.inc I've put this code to define or not the constant for a correct process, but It acts randomly with errors.
The code:
Code:
```IF ~defined UNICODE
display "UNICODE not defined,defining as FALSE",0Dh,0Ah
match any,UNICODE {UNICODE      EQU        FALSE}
;        match ,UNICODE {UNICODE      EQU        FALSE}
END IF

match =FALSE ,UNICODE {display "UNICODE defined as FALSE",0Dh,0Ah}
match =TRUE  ,UNICODE {display "UNICODE defined as TRUE",0Dh,0Ah}

WM_MESSAGEA = 100
WM_MESSAGEW = 200
IF UNICODE
WM_MESSAGE = WM_MESSAGEW
ELSE
WM_MESSAGE = WM_MESSAGEA
END IF
```

I've used "match any", and "match ", but they works fine only once, then I must change from one to the other,It's crazy!!!.

Try with that sequence:
1. Use "match any" and copile, without defining UNICODE [OK]
2. Define UNICODE as TRUE and copile, during the copilation it says that UNICODE is defined as false, not as TRUE!!! this is one error. [ERROR]
3. Now use "match " and copile, now it says that UNICODE is defined as TRUE, works fine!!! [OK]
4. Copile again, but without defining UNICODE, it shows an error when i use UNICODE, it's not defined!!! [ERROR]

I've tried to give you all the sequence, why does it happen? i need help.
11 Oct 2005, 17:08
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
"if" is not a preprocessor directive, read FAQ
11 Oct 2005, 17:14
kidscracker

Joined: 29 Oct 2004
Posts: 46
Location: Peru
kidscracker
So a possible solution wil be...??? may be there's one no ?
11 Oct 2005, 17:26
decard

Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
11 Oct 2005, 17:41
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7861
Location: Kraków, Poland
Tomasz Grysztar
Use "UNICODE = TRUE" instead of "UNICODE EQU TRUE" and then:
Code:
```IF ~defined UNICODE | defined @f
display "UNICODE not defined,defining as FALSE",0Dh,0Ah
@@: UNICODE = FALSE
END IF

WM_MESSAGEA = 100
WM_MESSAGEW = 200
IF UNICODE
WM_MESSAGE = WM_MESSAGEW
ELSE
WM_MESSAGE = WM_MESSAGEA
END IF    ```

I suggest reading the sections 2.2 and 2.3 of manual carefully. And remember that preprocessor (described in 2.3) does its all job before the multi-pass assembler and its control directives (described in 2.2) come in. I have extended section 2.3.7 to cover this.
11 Oct 2005, 22:36
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum