Friday, 15 May 2015

c - getnameinfo's signature changes between glibc versions, how can I match it? -



c - getnameinfo's signature changes between glibc versions, how can I match it? -

i need match signature phone call getnameinfo can write wrapper around call. unfortunately signature changes between hosts.

things working , going find until tried compile on latest centos, 6.3, gives error:

error: conflicting types 'getnameinfo'

huh?

it turns out final argument, flags, listed unsigned int on centos (glibc-headers-2.12-1.80) int on fedora (glibc-headers-2.15-58). (note man pages on both hosts should int.)

extern int getnameinfo ( /*cut*/, unsigned int __flags);

vs

extern int getnameinfo ( /*cut*/, int __flags);

some searching leads me believe the standard has changed type of flags argument.

it looks need alter type of flags in function match host's definition. what's best way deal problem? autoconf-type issue or there simpler solution? hoped compiler (gcc) have macro leverage can't find anything.

you check __glibc_minor__ macro defined in features.h , pass arguments accordingly, example:

#include <features.h> #if __glibc_minor__ > 12 getnameinfo(..., flags); #else getnameinfo(..., (unsigned) flags); #endif

c linux gcc posix

No comments:

Post a Comment