Gavin Deane said:
[...]
It's an example using <cstdio> rather than <cstring>, but MSVS2005
(language extensions disabled) and Comeau online both compile this:
#include <cstdio>
int main()
{
printf("This should not compile.\n");
}
That's enough for me to not bother with <cxxx> headers. YMMV.
Calm down. There's a difference between a compiler accepting
a program that *should* compile and one failing to compile a
program that *shouldn't* compile. And in this particular case,
the issues run even deeper. Several compiler vendors warned the
C++ committee that their rules for namespaces in <*.h> vs <c*>
headers were unrealistic, but their warnings were ignored. As a
consequence, the rules of C++98 have been largely ignored, to
repay the compliment, by *most* compiler vendors, not just
Microsoft. Now guess what -- the next C++ Standard (informally
known for now as C++0X) has finally accepted the obvious and
blessed the behavior you're seeing. So this is just a transient
hiccup, not a major sin.
Just to make my point of view clearer: I didn't mean to (overly)
criticize the implementors with my comments. My opinion was
very much that none of the implementations were conform,
*because* the requirements of the standard weren't really
reasonable (which I really should have said explicitly). Which
means, in a very real sense, that I don't know what I can count
on in the <cxxx> headers. I knew what most implementors did,
and I rather thought that it was a reasonable compromize, but
why count on it? What if the standard adopted a different
position in the future, in its attempts to become reasonable?
As for Gavin's comment: I agree. Why bother with the new
headers if they don't provide what the standard claims to
require? There's certainly no rush; the old ones aren't going
to disappear, and my code will work just as well with them.
Now that the standard has been clarified, I'll probably
reevaluate my position. Although somewhere deep inside me, I
still don't see any real reason for the <cxxx> headers---I'm
using a legacy, C API, so why hide the fact?
(This is, of course, independant of the atexit problem. Where
the library implementor is rather at the mercy of the compiler,
and whether it implements `extern "C"' correctly.)