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.
Definition of osteopathy : a system of medical practice that emphasizes a holistic and comprehensive approach to patient care and utilizes the manipulation of musculoskeletal tissues along with other therapeutic measures (such as the use of drugs or surgery) to prevent and treat disease : osteopathic medicine.
A Hands-On Approach DOs use osteopathic manipulative treatment (OMT) to help identify and correct the source of the underlying health concerns. They use this technique to help treat low back pain, as well as a variety of other health problems, including headaches and sinus issues.
A doctor of osteopathic medicine (D.O.) is a fully trained and licensed doctor who has attended and graduated from a U.S. osteopathic medical school. A doctor of medicine (M.D.) has attended and graduated from a conventional medical school.
Osteopathic manipulative therapy treats conditions that affect every system in the body, including the musculoskeletal system, digestive system, nervous system and immune system. By realigning the body and restoring balance to bones and muscles, OMT allows your entire body to work better as a whole.
The glibc manual describes each feature test macro (FTM) including _DEFAULT_SOURCE
:
If you define this macro, most features are included apart from X/Open, LFS and GNU extensions: the effect is to enable features from the 2008 edition of POSIX, as well as certain BSD and SVID features without a separate feature test macro to control them. Defining this macro, on its own and without using compiler options such as
-ansi
or-std=c99
, has the same effect as not defining any feature test macros; defining it together with other feature test macros, or when options such as-ansi
are used, enables those features even when the other options would otherwise cause them to be disabled.
This LWN.net article about FTMs provides us with a rationale (among other perhaps interesting info):
The original intent seems to have been that, within each of the glibc header files that employs FTMs, only one of the
__USE_*
internal macros should govern the exposure of any particular definition. Additionally, the macros should not be used in nested#ifdef
directives. An inspection of the glibc header files quickly shows that the reality is far from the intent, a situation that led Roland McGrath to suggest that it was time for a major cleanup to bring things back to the intended situation. Roland thought that task could be simplified by eliminating the_BSD_SOURCE
and_SVID_SOURCE
FTMs, which, although they had a purpose historically, have ceased to be useful these days. Anymore, he said, the only macros that are needed for modern source code are those that relate to formal standards plus_GNU_SOURCE
.Joseph Myers duly obliged with a series of patches to implement the first steps in this work. The conservative approach encouraged by Roland meant that the deprecation of the
_BSD_SOURCE
and_SVID_SOURCE
FTMs is taking place across two glibc versions. Version 2.19 of glibc added a new FTM,_DEFAULT_SOURCE
. Defining this macro causes the default definitions to be exposed even when the explicit definition of other macros would cause that not to happen. The effect of defining this macro is equivalent to the effect of explicitly defining three macros in earlier glibc versions:cc -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809C
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With