Closed jpellegrini closed 1 year ago
Hi @egallesio !
This seems to fix #528 ... I'm not sure it's the best way, but it was easy to implement, so here it is.
The commit message:
It is common practice to use
#define SOME_MACRO do{ \ ... \ ... \ }while(0)
so that SOME_MACRO can be used inside ifs and other C commands.
if
However, this can lead to problems:
#define NEXT continue ... ... for(;;) { ... #define LOCK_AND_RESTART do{\ if (!have_global_lock) { \ ... \ NEXT; \ } \ }while(0) ... } /* for(;;) */
The NEXT expands into continue, which will break out of the do, and not continue the for loop as intended.
NEXT
continue
do
for
So we insteda use if(1){ ... }else{} for all multi-command macros.
if(1){ ... }else{}
Hi @egallesio ! I'm closing this, since you have merged the other one! :)
Oops didn't see that you had a PR with if/else.
if/else
Hi @egallesio !
This seems to fix #528 ... I'm not sure it's the best way, but it was easy to implement, so here it is.
The commit message:
It is common practice to use
so that SOME_MACRO can be used inside
if
s and other C commands.However, this can lead to problems:
The
NEXT
expands intocontinue
, which will break out of thedo
, and not continue thefor
loop as intended.So we insteda use
if(1){ ... }else{}
for all multi-command macros.