This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Implementation of libc functions in std::
Philipp Thomas wrote:
>
> * Bernd Strieder (strieder@student.uni-kl.de) [20000829 19:47]:
>
> > inline math facilities have extern "C" linkage. To be compatible with
> > the standard we need them with C++ linkage in namespace std.
> >
> > My ideas to solve it are as follows:
>
> Check libstdc++ V3, included in the CVS version of gcc but not enabled by
> default because it's still under development. AFAIK, it has shadow headers
> that do put the C functions in std:: where required by the ISO C++ standard.
>
I have looked through it again. I have nothing found about putting those
functions into namespace std in those shadow headers. In contrary, they
seem to reintroduce them into the global namespace from std:: and other
namespaces.
The libstdc++-v3/bits/std_cmath header, I didn't look at before, is
quite interesting, because it defines inline wrappers in namespace std,
calling the corresponding functions in global namespace or compiler
builtins. The same is done in std_cctype, std_complex, and std_cwctype,
as is shown by:
/net/bernd/src/egcs-20000807/libstdc++-v3 > grep namespace bits/std_c*
bits/std_cctype.h:// namespace, and provide C++ inlines for them in the
std:: namespace
bits/std_cctype.h:namespace std
bits/std_cctype.h: // NB: If not using namespaces, can't have any of
these definitions,
bits/std_cctype.h: // as they will duplicate what's in the global
namespace.
bits/std_cctype.h:} // namespace std
bits/std_cmath.h:namespace std {
bits/std_complex.h:namespace std
bits/std_complex.h:} // namespace std
bits/std_cwctype.h:// namespace, and provide C++ inlines for them in the
std:: namespace
bits/std_cwctype.h:namespace std
bits/std_cwctype.h:} // namespace std
The other headers e.g. std_cstdlib.h, ... do nothing on that.
So after all this tells me that there is some unfinished work, i.e.
writing these inline wrappers in all remaining headers. Is that right?
Is there any chance to avoid those wrappers? E.g. by something like:
#include <std...h>
namespace std {
using ::fopen;
using ::fclose;
...
}
The inline wrappers need the functions in global namespace, too. So
there is nothing gained in cleaning up the global namespace.
Is there any hope that sometimes #include <cstd...> just creates names
in std:: namespace and nothing in global namespace? AFAIK this is needed
for standard compliance.
Bernd Strieder