home | list info | list archive | date index | thread index

"_GNU_SOURCE" versus "__USE_GNU"

  minor curiosity regarding GNU C library and feature test macros;
perhaps i'm just misreading.

from "man 3 getenv":

  SYNOPSIS
       #include <stdlib.h>

       char *getenv(const char *name);

       char *secure_getenv(const char *name);

   Feature    Test    Macro   Requirements   for   glibc   (see   fea‐
   ture_test_macros(7)):

       secure_getenv(): _GNU_SOURCE

so i would normally read that as that i need to define "_GNU_SOURCE"
before including stdlib.h to define the external reference to
secure_getenv(), but that doesn't work as this is what is in
/usr/include/stdlib.h:

  #ifdef __USE_GNU
  /* This function is similar to the above but returns NULL if the
     programs is running with SUID or SGID enabled.  */
  extern char *secure_getenv (const char *__name)
       __THROW __nonnull ((1)) __wur;
  #endif

and defining "__USE_GNU" makes it work just fine.

  what is the proper usage of feature test macros in such a case,
since the man page suggests one thing while the header file clearly
shows another. thoughts?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                         http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

replies

message navigation