A lot of duplicates here, I think.
The do...while(0) trick allows using errExit in various contexts without breaking anything:
if(x) errExit(msg); else return 1;
translates to:
if(x) do { ...; ...; } while(0); else return 1;
If you omit the do...while(0) , then you cannot reliably add a semicolon, for example.
source share