I was trying to implement a change to the macro which would make it safe, 
because we're using the call to this macro in lots of places and it would be 
hard to pinpoint all the problematic places.

I made the change like you describe earlier and figured I had to be doing 
something wrong, because it resulted in so many compile errors (macro is 
defined in an included file). Reading your explanation it showed the change was 
okay, but it had to be something else. Now making the change again I was able 
to trace all those compile errors back to the places where we wwere using the 
macro inside if-else-statements without brackets, being the places where things 
were silently going wrong.


Thanks!

Arjan

-----Oorspronkelijk bericht-----
Van: Martin Bähr [mailto:[EMAIL PROTECTED] 
Verzonden: Thursday, July 31, 2008 3:06 PM
Aan: Arjan van Staalduijnen
CC: [email protected]
Onderwerp: Re: 'if' with failing 'else' block

i don't think there is a safe way to do this with a macro.
you are taking a statement and make it look like an expression, yet it
really isn't. there will always be cases where this can break.

you could do something like:

#define do_log(X, Y...) { if ( !(< DBG, TME >)[T] ) low_log(X, Y); }

then you would get an error if you place a ; after do_log() before an
else (unless you have another block of {} around it.

an error is better than a random hard to see unusual behaviour.

i'd use a regular function instead of a macro though.

greetings, martin.

__________________________________________________________
Deze e-mail en de inhoud is vertrouwelijk en uitsluitend bestemd voor de 
geadresseerde(n). Indien u niet de geadresseerde bent van deze e-mail verzoeken 
wij u dit direct door te geven aan de verzender door middel van een reply 
e-mail en de ontvangen e-mail uit uw systemen te verwijderen. Als u geen 
geadresseerde bent, is het niet toegestaan om kennis te nemen van de inhoud, 
deze te kopieren, te verspreiden, bekend te maken aan derden noch anderszins te 
gebruiken.

The information contained in this e-mail is confidential and may be legally 
privileged. It is intended solely for the addressee. If you are not the 
intended recipient, any disclosure, copying, distribution or any action taken 
or omitted to be taken in reliance on it, is prohibited and may be unlawful. 
Please notify us immediately if you have received it in error by reply e-mail 
and then delete this message from your system.
__________________________________________________________



  • 'if... Arjan van Staalduijnen
    • ... Arjan van Staalduijnen
      • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
      • ... Marc Dirix
      • ... Martin Bähr
        • ... Arjan van Staalduijnen
          • ... Stephen R. van den Berg
            • ... Arjan van Staalduijnen

Reply via email to