This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: malloc.c defining an assert macro
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Samuel Thibault <samuel dot thibault at gnu dot org>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 29 Jan 2018 16:07:31 +0000
- Subject: Re: malloc.c defining an assert macro
- Authentication-results: sourceware.org; auth=none
- References: <20180127212803.7p2o37islkdrp5o3@var.youpi.perso.aquilenet.fr>
On Sat, 27 Jan 2018, Samuel Thibault wrote:
> Hello,
>
> In hurd builds, we get
>
> malloc.c:284:0: warning: "assert" redefined
> # define assert(expr) \
>
> In file included from ../include/assert.h:1:0,
> from ../sysdeps/mach/hurd/i386/tls.h:79,
> from ../sysdeps/i386/atomic-machine.h:20,
> from ../include/atomic.h:50,
> from malloc.c:216:
> ../assert/assert.h:107:0: note: this is the location of the previous definition
> # define assert(expr) \
>
> This is because <assert.h> happens to get pulled in by tls.h.
>
> Should malloc.c perhaps #undef assert before redefining it?
First, is there any reason malloc.c needs its own assert macro? If the
standard one is just as good, making malloc.c include <assert.h> and not
define its own macro at all would be the obvious fix.
--
Joseph S. Myers
joseph@codesourcery.com