-2

I am looking for the implementation files of the c++ standard library (the .cpp files) for the gcc compiler. For instance, where I can find the implementation of the method basic_istream& read( char_type* s, std::streamsize count ) of the istream class.

Here you find the ouput of gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.2-10ubuntu13' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13) 
El pupi
  • 458
  • 1
  • 3
  • 13
  • It depends entirely upon the compiler. – Dúthomhas Mar 20 '16 at 01:32
  • I think this is a legitimate question after the edits... There's a single (or very few) correct answer, and knowing the right keywords to search for this is not so trivial, that it'd be wrong to ask here. – hyde Mar 21 '16 at 13:56
  • @Thomas Could you add output of `gcc -v` to the question, to make it clear which *gcc* you are using. – hyde Mar 21 '16 at 14:01
  • 1
    In the GCC source code, see https://gcc.gnu.org/git/?p=gcc.git;a=summary - specifically in `libstdc++-v3/include/bits/istream.tcc` which is a header so you will have it installed as part of the C++ standard library. – Jonathan Wakely Mar 21 '16 at 14:35
  • @Jonathan Wakely : I don't need the header file. Headers are installed an available on the machine. I really need the .cpp file where some functions are defined. – El pupi Mar 23 '16 at 19:28
  • The function you asked about is defined inline in the header. If you're after some other functions then you should have said so, but you will still find them in the GCC source code, obviously. – Jonathan Wakely Mar 23 '16 at 19:45
  • 1
    I find the implementation file here https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3/src. I found istream.cc. But strangely I didn't find the `read` function. I checked on my header file and that function is not declared inline. – El pupi Mar 23 '16 at 19:53
  • Put the word in Searchlight and double click on the result. – QuentinUK Mar 27 '16 at 06:27
  • @Thomas: look in the file that JonathanWakely directed you to. – Michael Burr Mar 27 '16 at 07:04

1 Answers1

0

The gcc compiler does not implement the standard library. It is designed to be used in conjunction with a separate project that implements the standard library. This applies to both the C Standard Library, and the C++ Standard Library.

GNU/Linux systems commonly use glibc as the C Standard Library, and libstdc++ as the C++ Standard Library. Other choices are possible however.

M.M
  • 138,810
  • 21
  • 208
  • 365