[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Best test condition for defining _GNU_SOURCE?



Hi,

I have submitted a patch that needs to be modified to define _GNU_SOURCE
for definitions of various glibc functions, like get_current_dir_name,
declared in unistd.h if _USE_GNU is defined. __USE_GNU is defined by
using the feature macro _GNU_SOURCE. 

Not declaring get_current_dir_name creates problem for 64-bit
architectures:
warning: implicit declaration of function
‘get_current_dir_name’ [-Wimplicit-function-declaration]
warning: assignment makes pointer from integer without a cast [enabled by default]

Potential problems can arise see: http://wiki.debian.org/ImplicitPointerConversions

Is the following construct OK?
#ifdef __GNUC__
#define _GNU_SOURCE
#endif
...
#include <unistd.h>
...
#ifdef __GLIBC__
 new_path = get_current_dir_name();
...
#endif

Testing against __GLIBC__ does not work since no libc header files have
yet been included, leading to __GLIBC__ undefined. 

An alternate solution would be to use __GNU__ for both conditions, but
that would make the patch Hurd only (do we want that?)



Reply to: