GNOME Bugzilla – Bug 652602
unbreak compilation if NI_IDN is not defined
Last modified: 2012-01-07 18:03:50 UTC
Created attachment 189946 [details] [review] define NI_IDN to 0 if it's not already defined Hi. Under (at least) OpenBSD, NI_IDN is not defined and the compilation fails with: openfiles.cpp: In function 'char* friendlier_hostname(const char*, int)': openfiles.cpp:74: error: 'NI_IDN' was not declared in this scope The following patch fixes it by defined NI_IDN to 0 if not already defined. Thoughts?
Committed. Thanks.
*** Bug 583923 has been marked as a duplicate of this bug. ***
Please see my comments several years ago in Bug #583923 with concerns about the hard-coding solution? I stand by my main "how is hardcoding the value of a system-function token a safe-sounding idea" concern. NI_IDN affects the return-value of getnameinfo(), so if you're no longer sure whether that's happening (because you obscure whether that feature is present), downstream consumers of the return value have a bit of chaos. The effect of this solution is probably safe in this context, albeit confusing as hell to those of us who have to port this code to non-linux platforms. For example, the implemented solution is: #ifndef NI_IDN #define NI_IDN 0 #endif getaddrinfo(..., NI_IDN); A more self-documenting and less surprising ("Why does this not bomb? I know I don't have this glibc extension on my platform!" and leaving it obvious where others could help extend missing functionality) way would be: #ifdef NI_IDN getaddrinfo(..., NI_IDN); #else getaddrinfo(...); #endif And I stand by my "why is s-m apparently duplicating functionality available in other libraries" question about this code segment.