[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] dirname.h self-contained?

From: Bruno Haible
Subject: Re: [Bug-gnulib] dirname.h self-contained?
Date: Tue, 27 May 2003 13:56:26 +0200 (CEST)

Oskar Liljeblad writes:
> I don't know if the idea is to make each header file provided by
> gnulib self-contained or not

Yes it is desired that each .h file can be included without any
prerequisites and without ordering constraints. Now even glibc's
<regex.h> has become self-contained (since 2003-04-17).

> but if it is then dirname.h needs some #include for size_t. I guess
> the needed header file is <stddef.h>.

Right, for size_t you need <stddef.h> or <stdlib.h>. So if one needs
nothing from <stdlib.h> I prefer <stddef.h> since it is smaller.

> Also, browsing the other gnulib modules I encountered this:
> Most of the time stddef.h is included unconditionally

We are generally assuming ANSI C89 by now. See also

> but sometimes it is included like this (regex.h):

That's because regex.h is shared with glibc, and noone has so far
bothered to convince the glibc maintainers that removing K&R C
compatibility has a value in this case.

>   #if defined STDC_HEADERS || defined _LIBC
>   # include <stddef.h>
>   # include <stdlib.h>
>   #endif

I wouldn't write code like that. There is no reason to not #include
<stddef.h> and/or <stdlib.h> on IRIX 4 just because this system has a
non-standard <ctype.h>.

Jim Meyering wrote:

> IMHO, the way to do it is like this:
>  #include <stddef.h>
>  #include <stdlib.h>

And if all you need is size_t, then just <stddef.h> is enough.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]