/usr/include/stdlib.h
Every name in a .h
C stdlib header resides in the global namespace (obviously).
Additionally, any cHEADER
C++ stdlib header will define the corresponding names from HEADER.h
in the std
namespace, but is also allowed to have them in the global namespace (so they can just do
// cHEADER
#include <HEADER.h>
namespace std{
using ::one_name_from_HEADER;
using ::another_name_from_HEADER;
// and so on...
}
and be done with it).
§D.5 [depr.c.headers]
p2 Every C header, each of which has a name of the form name.h
, behaves as if each name placed in the standard library namespace by the corresponding cname
header is placed within the global namespace scope. It is unspecified whether these names are first declared or defined within namespace scope (3.3.6) of the namespace std and are then injected into the global namespace scope by explicit using-declarations (7.3.3).
p3 [ Example: The header <cstdlib>
assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h>
assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std. —end example ]
As you can see, the same is also true the other way around (<HEADER.h>
may introduces names to the std
namespace, as if
// HEADER.h
#include <cHEADER>
using std::one_name_from_HEADER;
using std::another_name_from_HEADER;
// and so on...
}
), which makes the whole distinction between those headers rather... useless, really.