I'm using Ariel Faigon's sort library, found here: http://www.yendor.com/programming/sort/
I was able to get all my code working on Linux, but unfortunately, when trying to compile with GCC on Mac, its default stdlib.h contains another heapsort, which unfortunately results in a conflicting types error.
Here's the man page for Apple heapsort: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/heapsort.3.html
Commenting out the heapsor开发者_JAVA技巧t in the sort library header causes a whole heap of problems. (pardon the pun)
I also briefly thought of commenting out my use of stdlib.h, but I use malloc and realloc, so that won't work at all.
Any ideas?
Isolate your use of Ariel Faigon's function in a single, tiny file that does not need to use <stdlib.h>
. Make sure you link Ariel Faigon's library before the standard C library.
You can try defining _POSIX_C_SOURCE
:
$ gcc -E /usr/include/stdlib.h | grep heap
int heapsort(void *, size_t, size_t,
int heapsort_b(void *, size_t, size_t,
$ gcc -E -D_POSIX_C_SOURCE /usr/include/stdlib.h | grep heap
# No output at all this time
Hopefully _POSIX_C_SOURCE
won't suppress anything that you need.
You can often get around these sorts of problems with some combination of _POSIX_C_SOURCE
, _BSD_SOURCE
, _XOPEN_SOURCE
, _KEEP_YOUR_STUPID_EXTENSIONS_OUT_OF_STANDARD_HEADERS
, ... Sometimes they fight each other though so you're left with source partitioning schemes as Jonathan Leffler suggests.
精彩评论