cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Defines/ifdefs name-scope

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 17 Feb 2006 23:12:23 +0100 (CET)

On Fri, 17 Feb 2006, Yang Tse wrote:

> It is just a very small step in the direction pointed by the TODO list of
> curl which states the following:
>
> "Make the curl/*.h headers include the proper system includes based on what
> was present at the time when configure was run. Currently, the sys/select.h
> header is for example included by curl/multi.h only on specific platforms we
> know MUST have it. This is error-prone. We therefore want the header files
> to adapt to configure results. Those results must be stored in a new header
> and they must use a curl name space, i.e not be HAVE_* prefix (as that would
> risk collide with other apps that use libcurl and that runs configure)."

I'll try to clarify what I mean:

Using HAVE_* defines is perfectly fine all over in curl's and libcurl's
sources. The HAVE_* defines are all defined by our own private header files or
by config.h that is generated by configure. They are also somewhat standard in
portable projects and thus this exact naming serves a purpose.

In the public headers however, the story is different. They are headers that
will be installed and used by applications that may or may not already use
HAVE_* defines of their own. We must not assume that HAVE_* defines are set
(since they may not be) and we must not define any HAVE_* defines (as they
would risk conflicting with the apps' way of doing the defines).

Currently our public headers don't rely on any defines set by configure for
these reasons. One particular thing we should do is make sure we include
<sys/select.h> in multi.h on systems that have it (since this is a known
problem area). So how do we do that? configure checks for the header and sets
the HAVE_SYS_SELECT_H define but we cannot use that define in the header file
as described earlier.

We probably want a include/curl/autoconf.h header (or similar) created that
contains CURL_HAS_SYS_SELECT_H and we use that define in multi.h. Then we can
properly install these headers on a system without risking a collide when apps
use these headers. These CURL_HAS_* defines are only necessary for the public
header files. Of course we need to take precautions so that the concept works
even for systems that can't run configure.

I hope this at least provided some more info.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-02-17