[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix use of ENABLE_NLS (which is not always defined)
From: |
Eric Blake |
Subject: |
Re: [PATCH] Fix use of ENABLE_NLS (which is not always defined) |
Date: |
Thu, 18 Mar 2010 09:51:18 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b1 Thunderbird/3.0.3 |
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 address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature