[Top][All Lists]

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

RE: Fixing malloc.h related warning

From: Boehne, Robert
Subject: RE: Fixing malloc.h related warning
Date: Tue, 16 Sep 2003 08:46:50 -0500

I'm not sure this is a good idea because other functions might be
pulled from malloc.h, or malloc() might be find in yet another header.
It's nearly impossible to know, you would need to be familiar
with every system function used by libltdl and where it resides
on every system known to man.  I think it is sufficient to do this
without the error message.  Really, I can't be sure that making the
change from including both to including stdlib.h only won't break
some system somewhere, but it probably won't.


-----Original Message-----
From: Dalibor Topic [mailto:address@hidden
Sent: Tuesday, September 16, 2003 5:19 AM
To: Bob Friesenhahn
Cc: Boehne, Robert; address@hidden
Subject: Re: Fixing malloc.h related warning

Bob Friesenhahn wrote:
> On Mon, 15 Sep 2003, Boehne, Robert wrote:
>>This would require a patch that looks for whatever malloc.h is #included for
>>in stdlib.h and prefers it in stdlib.h.  So it isn't as simple as 
> The question is how necessary is it to support non-ANSI C.  Stdlib.h
> is ANSI C standard while malloc.h is a legacy header.  The header is
> included in order to obtain prototypes for malloc() and free().  If
> the compilation environment is ANSI C, malloc.h should never be
> included.
> Probably this is sufficient:
> #if defined(HAVE_STDLIB_H)
> #include <stdlib.h>
> #else
> #if defined(HAVE_MALLOC_H)
> #include <malloc.h>
> #endif
> #endif

You may want to add an error message if none of the headers can be found 
to go sure that you don't get weird 'C compiler can't find declaration, 
so it makes assumptions about parameter types' problems:

#if defined(HAVE_STDLIB_H)
#include <stdlib.h>
#if defined(HAVE_MALLOC_H)
#include <malloc.h>
#error "Can not find a header declaring malloc."

if this is o.k., I'll submit a patch.

dalibor topic

reply via email to

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