Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #37155] compiler warning - missing prototype for posix_memalign()

38 views
Skip to first unread message

Joshua Hoblitt

unread,
Sep 13, 2005, 5:20:02 AM9/13/05
to bugs-bi...@rt.perl.org
# New Ticket Created by Joshua Hoblitt
# Please include the string: [perl #37155]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37155 >


Building with revision r9190 I get the following warning.

--
config/gen/platform/generic/memalign.c: In function `Parrot_memalign':
config/gen/platform/generic/memalign.c:12: warning: implicit declaration of function `posix_memalign'
--

Which seemed odd, as I know my platform provides posix_memalign. cpp
confirms that stdlib.h isn't providing the prototype.

--
$ cpp -DPARROT_HAS_POSIX_MEMALIGN config/gen/platform/generic/memalign.c | grep posix_memalign
int i = posix_memalign(&p, align, size);
--

Which makes sense, as neither _XOPEN_SOURCE or _GNU_SOURCE is #defined.
So I make the following change:

--
Index: config/gen/platform/generic/memalign.c
===================================================================
--- config/gen/platform/generic/memalign.c (revision 9190)
+++ config/gen/platform/generic/memalign.c (working copy)
@@ -3,6 +3,7 @@
*/

#if defined(PARROT_HAS_POSIX_MEMALIGN)
+#define _XOPEN_SOURCE 600
#include <stdlib.h>

void *
--

And now cpp is showing that the proper prototype is being sucked in.

--
$ cpp -DPARROT_HAS_POSIX_MEMALIGN config/gen/platform/generic/memalign.c | grep posix_memalign
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
int i = posix_memalign(&p, align, size);
--

So I run `make distclean && perl Configure.pl && make` and the warning
is *still* there (different line number).

--
config/gen/platform/generic/memalign.c: In function `Parrot_memalign':
config/gen/platform/generic/memalign.c:13: warning: implicit declaration of function `posix_memalign'
--

My only guess is that somehow _STDLIB_H is being defined before #include
in memalign.c is processed by cpp. This has a really bad smell to it.

This is on Linux/AMD64 w/ gcc-3.4.4 & glibc-2.3.5 and multilib header
files.

-J

--

0 new messages