3 ms·
Play stupid games, win stupid prizes. If you're passing an expression with side-effects (which should, in most cases, be on its own line) into a macro, you nee
by juliangoldsmith 10y ago
Play stupid games, win stupid prizes. If you're passing an expression with side-effects (which should, in most cases, be on its own line) into a macro, you need to make sure that macro behaves as you intend.
Writing good C code isn't impossible, it just requires more resources than writing poor C code. A lot of places aren't willing to put the resources in to write good, secure code, in any language.
- aidenn0 10y agoIf it's not possible to write function-like-macros that actually behave like functions, then function-like-macros need to be not used.
- mvkg 10y agoIt's a good recommended that you don't use them. https://www.securecoding.cert.org/confluence/display/c/PRE00-C.+Prefer+inline+or+static+functions+to+function-like+macros https://www.securecoding.cert.org/confluence/display/c/PRE00...
- mfukar 10y agoThis is a recommendation I've seen in most coding guidelines I've read.