This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

is _GNU_SOURCE defined by gcc ?


hi,
the followning simple code can prodcuce non-gnu both on red hat 6.2 and
7.0 (with the default gcc) at the same time with the latest cvs gcc 
it's print gnu. what is the difference and how can I force gcc to 
define _GNU_SOURCE (-D_GNU_SOURCE seems to be a solution but I don't
know whether is there any reason that it's not defined by default or not)?
-----------------
#include <iostream>

int main()
{
#ifdef _GNU_SOURCE
  std::cout << "gnu\n";
#else
  std::cout << "non-gnu\n";
#endif
}
-----------------
since if it's not defined many other defines (see below) from features.h
(glibc) won't defined so many glibc functions (eg.: pthread_mutexattr_settype) 
won't find, cause in this case _XOPEN_SOURCE is not defined and therefore
neither __USE_UNIX98...
-----------------
/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
#ifdef _GNU_SOURCE
# undef  _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
# undef  _POSIX_SOURCE
# define _POSIX_SOURCE  1
# undef  _POSIX_C_SOURCE
# define _POSIX_C_SOURCE        199506L
# undef  _XOPEN_SOURCE
# define _XOPEN_SOURCE  600
# undef  _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
# undef  _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE    1
# undef  _BSD_SOURCE
# define _BSD_SOURCE    1
# undef  _SVID_SOURCE
# define _SVID_SOURCE   1
#endif
-----------------


 -- Levente                        http://petition.eurolinux.org/index_html
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]