[PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

Richard via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 09:45:37 PST 2016

LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D17484#358617, @alexfh wrote:

> Thank you for this check! Mostly looks good, but there are a number of style nits.
> The most important question to this check is that the standard doesn't guarantee that the C++ headers declare all the same functions **in the global namespace** (at least, this is how I understand the section of the standard you quoted).

Oh crap, I totally forgot about this.  Yes, I believe the weasel wording in the standard is that an implementation may put the symbols in the global namespace as well as inside `std` when the C++ header is used, but is not required to put them in the global namespace.  They are required to put them in namespace `std` when the C++ header form is used.

So if you switch to C++ headers, you code may still compile, but it is implementation dependent.

If you use the C headers, you can't prefix symbols with `std` because they won't be there.

In other discussions of this topic, it was considered best to make both changes at the same time: switch to the C++ header and decorate the symbols with `std` prefix.

It would be reasonable for this check to insert a `using namespace std;` at the top of the translation unit after all the `#include` lines as a means of preserving meaning without trying to identify every symbol that needs `std` on it.


More information about the cfe-commits mailing list