Previously I was receiving warnings from gcc -std=c99
that usleep()
was implicitly declared. Then I stumbled across this stackoverflow post, which led me to use -D_BSD_SOURCE
. However, now gcc
tells me that -D_BSD_SOURCE
has been deprecated and I should use -D_DEFAULT_SOURCE
instead.
#warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
Why is -D_BSD_SOURCE
deprecated? Why is -D_DEFAULT_SOURCE
used instead? And what does it do?
I did some googling, and the results are just filled with people using it to shut gcc
up. I couldn't find out why -D_BSD_SOURCE
has been deprecated, just that it is.
The glibc manual describes each feature test macro (FTM) including
_DEFAULT_SOURCE
:This LWN.net article about FTMs provides us with a rationale (among other perhaps interesting info):
So if you need to define
_BSD_SOURCE
or_SVID_SOURCE
, simply define_DEFAULT_SOURCE
too. glibc versions <= 2.18 don't care about it and versions >= 2.19 don't warn if both or all three are defined.i need portability beyond linux and beyond glibc, and i dislike #ifdef's. so: