Is this code standard conforming?
#include <stdio.h>
#include <cstdio>
int main() {
FILE *f1 = 0;
std::FILE *f2 = f1;
}
Explanation: The standard says [headers]:
[…] the contents of each header
cnameshall be the same as that of the corresponding headername.h[…] as if by inclusion. In the C++ standard library, however, the declarations […] are within namespace scope (3.3.6) of the namespacestd. It is unspecified whether these names are first declared within the global namespace scope and are then injected into namespacestdby explicit using-declarations (7.3.3).
So in case they aren’t injected by explicit using-declaration, may they be different type? I don’t think the “as if by inclusion” phrase is conclusive since the other half of the text clearly contradicts this requirement, requiring the names are within the std namespace.
I don’t believe that paragraph says that they have to be identical. It is just a revision of the original (C++98) paragraph which said:
This was between hard and impossible to follow, because it conflicted with the existing real C headers on most systems. So, in C++11 the text was changed to the one you quote. It allows implementations to it the other way round, like they in practice have done all along – use existing system provided C headers and import the names to namespace
std.However, there is another paragraph saying that whichever way the implementation does this, the names in the headers must mean the same thing: