Am 29.01.2013 11:03, schrieb Markus Armbruster: > Andreas Färber <afaer...@suse.de> writes: > >> b) Working around an issue resulting from hiding C statements inside a >> preprocessor macro is totally backwards compared to properly using the C >> language in the first place. Its mechanism for reuse are functions, and >> for performance considerations static inline functions. > > Nobody denies inline functions are to be preferred in many cases. > > Valid exceptions include cases where we want genericity, which a macro > can easily provide, but an inline function can't. > >> Therefore I disagree with you that b) is not an entirely different >> disussion as you repeatedly suggest and that according to a) it is not >> *generally* necessary to put do { ... } while (0) into any random macro >> that one writes. It depends on the contents and on the context. > > I don't think Peter suggested to put do ... while (0) into random > macros! He asked to put it exactly into *statement-like* macros, as per > standard C practice. Most macros are expression-like.
Quoting PMM from last night: <<< "do ... while (0)" is completely standard practice for writing robust macros in C. Patches which don't do that should fail code review. >>> This is what sparked the most heated part of this debate! I completely object to this generalized statement without restriction to statement-like macros. > I think you're overstating your case. Statement-like macros should be > rare. This RFC was just a beginning. An average 50%+ of per target-*/ files contained macros that were touched here. Even more files are in hw/. Per file it was up to ~5 such macro definitions. And my main issue is deriving a convention for new files from this discussion. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg