Post by David GolubIn answer to your question, my understanding is that the current C++
standard explicitly permits xxxx.h to include cxxxx when compiling in C++
mode.
I went to some trouble to create headers that conform accurately to the
C++1998 and C++2003 standards in regards to the handling of namespaces. In
particular...
In C++, the <cname> headers *only* introduce the standard names into namespace
std. They do not introduce the standard names into the global namespace
(doing so was forbidden according to the existing standard). However, the
<name.h> headers introduce the standard names in both namespace std and the
global namespace. That's what our current implementation does. They do this
by #including the corresponding <cname> header and then apply using
declarations to hoist the names out of namespace std into the global space.
This is specifically allowed by the existing standard.
In C, the <name.h> headers just introduce the names in the global namespace
directly and, naturally, don't mess around with namespace std. Note the
conditional compilation directives in the file that cause C and C++ to see
different material.
Most library providers were lazy in this regard and did things the other way
around. They provided <cname> headers that included the corresponding
<name.h> header and then applied using declarations to inject the standard
names into namespace std. For example
#include <cstdio>
int main( )
{
printf("Hello, World!\n");
return 0;
}
The above does not compile with Open Watcom. The name "printf" needs to be
qualified like this: std::printf. However it *does* compile with certain
other compilers such as g++ and Visual C++... despite the fact that the
existing standard clearly forbids such usage. I've seen discussion on the C++
newsgroup about how the standard's requirements are "impossible" to
implement, etc, but frankly I don't see it. Aside from being a bit tedious,
it wasn't rocket science to set it up.
Anyway the new standard specifically allows either approach. It
is "unspecified" if the <name.h> headers hoist standard names out of
namespace std or if the <cname> headers inject names into namespace std. Our
implementation still conforms, but then so do the sloppy ones too. Ah well.
To the issue at hand. Jehuda I also don't quite follow what you mean. If you
could provide a short code sample of something that doesn't compile but
should, that would be helpful.
Regarding overloading... the names std::abs, std::labs, etc, are already being
overloaded in C++ code... as required by the existing standard. Setting it up
was a bit tricky as I recall but again, not rocket science. If there are new
functions in C++0x that overload with C99 functions I imagine we could set it
up similarly. Take a look at bld\hdr\watcom\stdlib.mh and see what you think.
Peter