-3

Each header from the C Standard Library is included in the C++ Standard Library under a different name, generated by removing the .h, and adding a 'c' at the start, for example 'time.h' becomes 'ctime'. The only difference between these headers and the traditional C Standard Library headers is that where possible the functions should be placed into the std:: namespace (although few compilers actually do this).

Since c functions are put into the std:: namespace,I tried :

man std::printf

but got :

No manual entry for std:printf

Any reasons?(I've installed libstdc++-doc and I've no problem with canonical c++ stuff like man std::cout)

UPDATE

The reason to say c++ is junky at least includes:

  1. junky c++ manual
  2. an empty c++ programe needs libstdc++,libm and libgcc_s,while c programe only needs libc.
Je Rog
  • 5,675
  • 8
  • 39
  • 47
  • 2
    The fact that the `man` command on your system doesn't account for C++ namespace semantics doesn't really have anything to do with the merits of the C++ language. – Jim Lewis Jun 11 '11 at 17:02
  • 2
    Why did you have to add that "C++ is junky" comment in your question? it's entirely unnecessary, adds no value to your question, and will only serve to annoy people. Please remove that. – Mat Jun 11 '11 at 17:10
  • @Mat ,because I totally agree with the author of gwan: http://trustleap.com/archives/gwan_linux.pdf – Je Rog Jun 11 '11 at 17:13
  • 1
    neither of your two points are C++ failings in any way. The documentation on some platforms has nothing to do with the language, and implementation details like dynamic library links aren't even part of the language. you just posted two rants about documentation and an specific implementation on a specific platform. What does that achieve? – Mat Jun 11 '11 at 17:20

2 Answers2

2

There really is no point in documenting the C++ functions that come from standard C if they are identical and are already documented (like printf is).

Mat
  • 202,337
  • 40
  • 393
  • 406
  • @Mat,I made a mistake in my post as `man std::cout` doesn't output anything,`man std::iostream` does. Looks odd. – Je Rog Jun 11 '11 at 16:13
  • what does `std::cout` have to do with "imported C functions"? – Mat Jun 11 '11 at 16:17
  • @Mat,I actually have quite a few questions with c++ manual,how do c++ guys actually use `man`?Sorry to pipe multiple into one. – Je Rog Jun 11 '11 at 16:20
  • I don't know about C++ guys, but I don't use man pages for C++ stuff. Google has better search features IMO. man pages are great for C/POSIX/system things though. – Mat Jun 11 '11 at 16:23
  • @Je Rog: Most of C++ guys would use a C++ Reference like [this](http://www.cplusplus.com/reference/) cplusplus is considered to provide incorrect documentation in certain cases though. – Alok Save Jun 11 '11 at 16:26
  • Oops,so `libstdc++-doc` is junky for c++ . – Je Rog Jun 11 '11 at 16:27
  • No, libstdc++-doc is not junky, it's just not the handiest tool around for the job, and certainly specific to one implementation of the Standard library. – rubenvb Jun 11 '11 at 17:13
2

The behavior of the C standard library functions is out of the control of libstdc++ developers. It relies (in this and most other C++ Standard library implementations) on the underlying platform's Libc implementation. On Linux, that's most probably glibc, on Windows, msvcrt, etc...

The point is that all these different libraries provide different and non-conforming behavior, which would have to be documented in the libstdc++ documentation, and that is impossible (no, very hard) to do and maintain. It also serves no practical purpose, as this documentation exists elsewhere.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • Apart from that,one more thing I don't think reasonable is that c++ splits c++ standard library into multiple shared objects like `libstdc++`,`libm`,and `libgcc_s`(these 3 libraries is need for an empty `main` ) while c standard library wraps everything in `libc` – Je Rog Jun 11 '11 at 16:35
  • Wow, hold on there! There's no splitting being done by "C++"! `libstdc++` is the only C++ library in your shortlist. `libm` is basically the C math library, and `libgcc_s` is one of GCC's runtime support libraries. If you don't want any shared objects, link with `-static`. If you don't want `libm`, well, that's tough, and you'll need to be careful what you parts of `libstdc++` you do use. Compile with `-fno-exceptions` to et rid of `libgcc_s`, but then of course, you'll be missing out on, well, exceptions. And don't worry so much about these details, nothing you can do about them anyway... – rubenvb Jun 11 '11 at 16:41
  • Why libm and libgcc_s aren't required for a simple c app? The c short list only contains libc,while c++ list has 3 by default. – Je Rog Jun 11 '11 at 16:45
  • Well, once you use anything from the C header ``, you'll need `libm`. C doesn't have exceptions. `libstdc++` uses a lot of math functions intrinsically. With power comes code, what did you expect? `libstdc++` isn't implemented in platform-dependent assembly... It's written in code, code that uses C code, which is in libraries. And if you link with `g++`, you don't have to worry about specifying libraries like this. It knows about them, and automatically links them in. – rubenvb Jun 11 '11 at 17:10