cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_setopt and typeof

From: Jamie Lokier <jamie_at_shareable.org>
Date: Sun, 13 Apr 2008 17:12:59 +0100

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.

This is not true, even on common architectures.

A simple example demonstrates it.
Please see my recent post with subject 'Not passing "long" to varargs'.

Normal (non-varargs) functions have prototypes; that is why they are
able to accept smaller types and behave correctly. Behind the scenes,
the compiler adds type conversions.

Varargs are like old-style functions without prototypes, and you have
to be more careful with them. The compiler does not know when to add
type conversions for these, so you have to do it explicitly.

-- Jamie
Received on 2008-04-13