| Akim Demaille writes:
| > I think Autoconf should advocate a single approach.  
| 
| Yup.
| 
| > Also, is `HAVE_WORKING_FOO' the right naming scheme?  Is it powerful
| > enough to allow us the specify the various brokenness that this or
| > that function may have?  Should HAVE_WORKING_FOO always be the `or' of
| > HAVE_FOO_BLAHBLAH_BUG, HAVE_FOO_SOMEOTHER_BUG etc.?
| 
| "Working" is a fairly volatile term. free() "works" if it frees memory. If
| it doesn't grok null pointers, that's an unfortunate circumstance but not
| necessarily "not working" by all standards.
| 
| What's the point? Who's going to write
| 
| #if HAVE_FREE_NULL_BUG
| if (mem != NULL)
|   free(mem)
| #else
| free(mem);
| #endif
| 
| everywhere? Some people that think they're smarter than optimizing
| compilers might try to pull stunts like that, but really...

Your example is excellent: precisely if I want a POSIX free, I will
have a file free.c with

void
free (void *mem)
{
#if HAVE_FREE_NULL_BUG
  /* Use the native free. */
# undef free
  if (mem != NULL)
    free (mem)
#else
  /* Work around some other bugs. */
  ...
#endif
}

Then, all I need is to AC_LIBOBJ(free) and AC_DEFINE(free, rpl_free),
and voilą!

So yes, you sometimes want to know what are the failures you face, in
particular when you want to write a wrapper around a broken
implementation.

| On the other hand there are things like snprintf, most implementations of
| which are not "working", but it's easy to provide your own snprintf.o that
| works (unlike free and realloc, which are a little harder to replace). In
| that case you should just test whether everything works or else use your
| good version.

Agreed, for some it might be overkill, but I want something uniform :)
That's why I propose the two systems together: a simple one
(HAVE_WORKING_FREE), and a fine one (HAVE_FREE_NULL_BUG).

| Also, these sort of tests will inevitably have problems with
| cross-compilers.

Well, this doesn't mean you must avoid them :)  Anyway, in that case
there is a recommendation coming from Autoconf: be pessimistic, and
consider you face all the problems altogether :)

Reply via email to