curl-library
Re: yangtse: curl/lib sendf.c,1.125,1.126 sendf.h,1.33,1.34
Date: Wed, 28 Mar 2007 08:44:53 +0100
Dan Fandrich wrote:
>On Tue, Mar 27, 2007 at 11:53:02AM +0100, Jamie Lokier wrote:
>
>>Why not this, to optimise away the function call in most cases?
>>
>> #define infof if (1) {} else Curl_infof
>
>This is going to give "code not reachable" warnings on some compilers, and
>will still leave the strings in the binaries on others.
An alternative is to avoid variadic macros altogether i.e.:
#define info0(d,f) Curl_infof(f)
#define info1(d,f,a1) Curl_infof(f,a1)
#define info2(d,f,a1,a2) Curl_infof(f,a1,a2)
#define info3(d,f,a1,a2,a3) Curl_infof(d,f,a1,a2,a3)
..etc. (7 is the max args I found on a quick scan)
This does impose a slight burden on the libcurl developers (remembering
to count the args of any new info calls). And a one-off cost in
changing the 200-odd existing calls. However, I believe it completely
avoids all problems with compiler dependencies and optimisations (or lack
of).
-- Colin HogbenReceived on 2007-03-28