On 03/18/2010 09:45 AM, Grégoire Sutre wrote: >> In >> general, we prefer to avoid #if inside function bodies; it is easier to >> read code where all the #if have been factored out to file scope level >> and function bodies are straight-line code. > > I agree that functions can be difficult to read when they contain #if > conditions. However, these cannot be avoided when the types of the > function's local variables depend on them.
Ah, but even then, gnulib prefers: #if COND typedef param_type unsigned int; #else typedef param_type int; #endif int func (param_type param); over: int func ( #if COND unsigned #endif int param); for (hopefully obvious) readability reasons. Yes, there are cases where in-function preprocessor directives are necessary, but its surprising how many times we've been able to factor them out. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature