bug-gnulib
[Top][All Lists]
Advanced

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

[bug-gnulib] Re: automatic prototypes


From: Simon Josefsson
Subject: [bug-gnulib] Re: automatic prototypes
Date: Thu, 16 Dec 2004 16:57:42 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

address@hidden (Karl Berry) writes:

>     > +#if defined HAVE_DECL_STRDUP && !HAVE_DECL_STRDUP
>     > +/* Duplicate S, returning an identical malloc'd string.  */
>     > +extern char *strdup (const char *s);
>     > +#endif
>
> Maybe it's not relevant, but don't far more programs use xstrdup than
> strdup?  I know that libraries may use strdup to avoid fatal errors, but
> except for Simon's case, are there (m)any others?

xstrdup is not standard, so for that I think it would actually improve
readability to add:

/* Get xstrdup, xmalloc, ... */
#include "xalloc.h"

But I don't think the same holds for strdup.  I should be able to
simply assume strdup.  I.e., I think adding the following is bad:

/* Get strdup. */
#include "strdup.h"

I guess this is a matter of preference, though...

Further, I guess exactly which standard people want to assume also
differs.  Some might want to assume C89, some C99, some POSIX, and
some GNU (like me).  By adding things to config.h, gnulib could
achieve that.

I think this means strdup.h should stay, for those that only want to
assume C89, and actually do want to #include "strdup.h" manually.
Having config.h duplicate that information shouldn't hurt.

> I had the impression that this sort of stuff went into a per-project
> "system.h" which included config.h, did declarations like the above,
> etc.  Isn't that safer than putting it directly in config.h?

Maybe.  However, that file would have to be synchronized closely with
internal details in gnulib, so I prefer to have gnulib hide as much as
possible for me.

Also, I'm trying to avoid the system.h approach.  I have a tendency to
add more and more stuff into it, until there is so much stuff in it
that it become impossible to separate parts of my project into
self-contained modules.

And finally, moving #include's into each file make it more clear which
file depend on which other files.  With system.h, I would never notice
if some of it was never needed.

Perhaps this behavior should be optional, somehow...  Put definitions
like that into a separate m4 function in the m4/ file and add a line
in the modules/ file that is added to gnulib.m4, when gnulib-tool is
invoked with --prototypes-in-config.h?

Thanks,
Simon





reply via email to

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