News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Translating C++ Conditionnal compilation

Started by ToutEnMasm, June 21, 2005, 07:20:18 AM

Previous topic - Next topic

ToutEnMasm

hello,
Is there an equate for the C++ expression
#if defined (_MSC_VER) && (_MSC_VER >= 1020)

IFDEF (masm) allow only one condition.Only IF accept multiple conditions,but there is'nt equate for "defined",&& can be translate by "AND", and ">=" by GE.

Is there somebody have an idea ?.




MichaelW

I have not tested this, but how about:

    IFDEF _MSC_VER
      IF (_MSC_VER GE 1020)
          ;(_MSC_VER defined) && (_MSC_VER >= 1020)
      ENDIF
    ENDIF

eschew obfuscation

Jeff

if you had a macro function that determines whether or not a symbol was defined, it could help things move along quite nicely.  :)

DEFINED MACRO symbol
    IFDEF <symbol>
        EXITM <-1>  ;;symbol defined
    ENDIF
    EXITM <0>       ;;symbol not defined
ENDM

IF DEFINED(_MSC_VER) AND (_MSC_VER GE 1020)
   ;...
ENDIF
although, i personally would have it seperated into 2 if starements (still using the DEFINED macro) because _MSC_VER might not be defined and the following _MSC_VER GE 1020 might give unexpected results (or at least i dont know what would happen).

MazeGen

Yes, in MASM, it is unhandy to test it all at one line, because when _MSC_VER is not defined, you get error:

Quoteerror A2006: undefined symbol : _MSC_VER

And that's not how it works in original C expression.

Eóin

_MSC_VER will never be defined anyway for Masm so why bother even translating that part :bg .

Jeff

he might have defined it for himself.  ;)

ToutEnMasm

Hello again,
I have Found

NOTDEFINED MACRO symbol
    IFNDEF symbol
   ECHO notdefined vrai
        EXITM <-1>  ;;symbol non defined
    ELSE
   ECHO notdefined faux
    EXITM <0>       ;;symbol  defined
    ENDIF
ENDM

DEFINED MACRO symbol
    IFDEF symbol
    ECHO defined vrai
        EXITM <-1>  ;;symbol defined
    ELSE
   ECHO defined faux
    EXITM <0>       ;;symbol not defined   
    ENDIF

ENDM

COMPARE MACRO constant,argument,value
IFDEF constant
   IF constant argument value
      ECHO comparaison vrai
      EXITM <-1>
   ELSE
      ECHO comparaison fausse
      EXITM <0>   
   ENDIF
ELSE
   ECHO pas défini
   EXITM <0>
ENDIF
ENDM

;--------------- and we can resolve complex statement like that -----------------------

RAJOUT equ 50
_MSC_VER equ 2000
MACHIN equ 456

IF COMPARE (_MSC_VER,GE,1000) AND COMPARE (RAJOUT,GE,40) AND NOTDEFINED (MACHIN)   ;
ECHO If vrai
ELSE
ECHO IF faux   
ENDIF


Thanks for the help
                                ToutEnMasm