Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

explanation of D_GNU_SOURCE Why to use it and when?

Tags:

c

linux

I know it is a Macro we are passing to a function. How do you explain what is the use of this macro, and in which scenario i have to use this ?.

like image 749
Whoami Avatar asked Jan 12 '12 14:01

Whoami


2 Answers

_GNU_SOURCE enables GNU extensions to the C and OS standards supported by the GNU C library, such as asprintf. Define it when you're using such non-standard functions and macros.

like image 83
Fred Foo Avatar answered Sep 27 '22 19:09

Fred Foo


From glibc manual:

Macro: _GNU_SOURCE

If you define this macro, everything is included: ISO C89, ISO C99, POSIX.1, POSIX.2, BSD, SVID, X/Open, LFS, and GNU extensions. In the cases where POSIX.1 conflicts with BSD, the POSIX definitions take precedence.

http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html

like image 27
ouah Avatar answered Sep 27 '22 21:09

ouah