I understand that the prototypes of the functions are in the respective header files. The declarations of standard functions are in the standard library and that is why we use the term "using namespace std". But where are the declarations of non-standard functions stored?
1 Answers
The standard library does not have to be implemented as header files.
The C++ standard dicates what happens when you #include <vector>
. It does not require that vector
be a header file on your system; it could be implemented as a compiler intrinsic that introduces certain symbols and types.
It dictates what happens when you interact with those symbols and types.
It is usually easy to do this as a header file; but there are some C++ features in std
that cannot be implemented in C++. Usually the "surface" interaction is done in C++, but they then fall back on magic compiler intrinsics.
Much of std
can exist and does exist as pure header files. Other parts of it are usually compiled into libraries, often mostly written in C or C++. They interact with operating system libraries, which are also mostly written in C (and sometimes C++ and other languages), which in turn talk to hardware specific code written in a mixture of C and assembly.
The "runtime" library can be dynamically or statically linked to your output, and acts as a kind of "glue" between what C++ requires and what the specific OS provides.
Other libraries can exist. Their header files are stored in a compiler-determined way and searched for in a compiler-determined way. Linking of their libraries, dynamically or statically, is also done in a compiler-determined way, as is where said libraries exist.
They can be written in many languages, so long as they export an interface that matches the ABI that the compiler expects.
std
namespace. Usually in the global namespace. – Some programmer dude