4 ms·
The do-while "nonsense" is a pretty standard construct, so much so that I'd never seen your approach - which I admit looks nicer. How well is that supported acr
by tb 17y ago
The do-while "nonsense" is a pretty standard construct, so much so that I'd never seen your approach - which I admit looks nicer. How well is that supported across different compilers? Is it part of C99, for example?
- paulbaumgart 17y agoNo, it's not in C99: http://www.redhatrenewals.com/docs/manuals/enterprise/RHEL-4-Manual/gcc/c-extensions.html http://www.redhatrenewals.com/docs/manuals/enterprise/RHEL-4... Admittedly I have little experience with compilers other than GCC, but all things considered, I'd shy away from using anything but really basic macros without the compound-statement-in-parens and typeof() extensions that GCC provides. Perhaps I spoke too harshly, calling it "nonsense". :-)
- paulbaumgart 17y agoSo, just to follow up, I saw that the OCUnit macros ( http://www.sente.ch/software/ocunit/ http://www.sente.ch/software/ocunit/ ) are all using defined using the do...while(0) guard. I was wrong. It's the more platform independent way to do things. For code that's only ever going to be compiled with GCC, though, the statement expression method is cleaner, I think.
- tedunangst 17y agoIt's only supported by gcc and some edg based compilers. edg has trouble with it in some c++ code. Just think of how adding this complicates your grammar.