I need to match the signature for the call getnameinfo so I can write a wrapper around that call. Unfortunately the signature changes between hosts.
Things were working and going find until I tried to compile on the latest CentOS, 6.3, which gives the error:
error: conflicting types for 'getnameinfo'
Huh?
It turns out that the final argument, flags, is listed as an unsigned int on CentOS (glibc-headers-2.12-1.80) but is just an int on Fedora (glibc-headers-2.15-58). (Note that the man pages on both hosts say it should be an int.)
extern int getnameinfo ( /*cut*/, unsigned int __flags);
vs
extern int getnameinfo ( /*cut*/, int __flags);
Some searching leads me to believe that the standard has changed the type of the flags argument.
It looks like I need to change the type of flags in my function to match the host's definition. What's the best way to deal with this problem? Is this an autoconf-type issue or is there some simpler solution? I hoped that the compiler (gcc) would have some macro I could leverage but I can't find anything.
you could check the __GLIBC_MINOR__
macro defined in features.h
and pass the arguments accordingly, example:
#include <features.h>
#if __GLIBC_MINOR__ > 12
getnameinfo(..., flags);
#else
getnameinfo(..., (unsigned) flags);
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With