libtool
[Top][All Lists]
Advanced

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

Re: Fixing malloc.h related warning


From: Dalibor Topic
Subject: Re: Fixing malloc.h related warning
Date: Tue, 16 Sep 2003 12:19:29 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312

Bob Friesenhahn wrote:
On Mon, 15 Sep 2003, Boehne, Robert wrote:


Dalibor,

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 
s/malloc/stdlib/.


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>
#else
#if defined(HAVE_MALLOC_H)
#include <malloc.h>
#else
#error "Can not find a header declaring malloc."
#endif
#endif

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

cheers,
dalibor topic





reply via email to

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