'explanation of D_GNU_SOURCE Why to use it and when?
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 ?.
Solution 1:[1]
_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.
Solution 2:[2]
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
Solution 3:[3]
Some functions not mandated by the standard are provided in libraries, but are only available when some feature test macro is defined. _GNU_SOURCE is one of the macros that makes such functions available.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fred Foo |
| Solution 2 | ouah |
| Solution 3 | Daniel Fischer |
