For compatibility with the C standard library and the C Unicode TR, the C++ standard library provides the 25 C headers, as shown in Table 154.
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 unspeciﬁed whether these names are ﬁrst declared or deﬁned within namespace scope of the namespace std and are then injected into the global namespace scope by explicit using-declarations.
[ Example: The header <cstdlib> assuredly provides its declarations and deﬁnitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly provides the same declarations and deﬁnitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std. — end example ] - IS
It was stupid of me to not see the header file itself before posting. Sorry. MS has first defined the header file in global namespace and then imported them into std using using.I might be wrong in some cases as there are a lot of #defines. I have only analysed that part which the IDE didn't grey out.
But why have the MS guys done it? Does it offer some advantage to keep identifiers in the global namespace?
Also, I've noticed that including <iostream> automatically seems to include <cstring> and <cstdio>. (I haven't actually seen the #includes, but the functions of those libraries work). Is this behaviour standard? If I forget to include to <cstring>, is it going to make my code not run on other compilers?
> Does it offer some advantage to keep identifiers in the global namespace?
I Suppose it is convenient for the implementers in cases where C++ parameter passing and return does not clash with the C mechanism; one does not have to write a separate <stdio.h> for C and another for C++.
> Also, I've noticed that including <iostream> automatically seems to include <cstring> and <cstdio>.
> Is this behaviour standard?
The standard allows it; an implementation may include one standard header in another.
> If I forget to include to <cstring>, is it going to make my code not run on other compilers?
The only assured, portable way to use std::strlen() is to #include <cstring> The only assured portable way to use ::strlen() is to #include <string.h>
If control reaches the end of a function without encountering a return statement, return; is executed (except in the main function, where return 0; is executed).
Flowing off the end of a value-returning function (except main) without a return statement is undefined behavior.