cURL / Mailing Lists / curl-library / Single Mail


Re: curl_easy_setopt and typeof

From: Nathan E. Moore <>
Date: Sun, 13 Apr 2008 13:42:08 -0400

--On Sunday, April 13, 2008 9:14 AM -0700 Dan Fandrich
<> wrote:

> On Sun, Apr 13, 2008 at 11:29:58AM -0400, Nathan E. Moore wrote:
>> It is irrelevant what the docs say it is perfectly legal to pass a
>> smaller type to a varargs function expecting a larger one. It will just
>> work, just like it would for a normal function. There is no reason the
>> type checker should be more restrictive than c. It should allow
>> anything that can be promoted to long (char, short, int long,
>> bitfields, enums).
> curl_easy_setopt is a varargs function, so there won't be any automatic
> promotion. You have to cast the value yourself if it's not exactly what's
> expected.
>>>> Dan

Section The va_arg macro (also available at
The parameter type shall be a type name specified such that the type of a
pointer to an
object that has the specified type can be obtained simply by postfixing a *
to type. If
there is no actual next argument, or if type is not compatible with the
type of the
actual next argument (as promoted according to the default argument
promotions), the
behavior is undefined, except for the following cases:
— one type is a signed integer type, the other type is the corresponding
unsigned integer
type, and the value is representable in both types;
— one type is pointer to void and the other is a pointer to a character

I guess the way I read it says that you do get argument promotion. I would
assume the
promotion would be done prior to pushing the arguments onto the stack. But
I have been
wrong before and likely will be again.

Nathan Moore
Received on 2008-04-13