Saturday, May 9, 2009

C and C++ standard library?

Are the function implementations in the standard library already in object code or are they in source code that must be loaded before the compiler runs so that they can be compiled.

C and C++ standard library?
The standard libraries are created by only the object code. By the object code we can create our own header files also. It is for reducing our code complexity. For using the header files with our programmer, the object code is enough. and also for become to usage of header files only the object code is loaded. That's it.
Reply:Hi there. I'm not sure what you mean by "already in object code"... if by "object" you are referring to the executable file generated by the compiler and NOT the object-oriented version of "object", then the answer is no, because there before compiling, there IS no object file. If you mean the object-oriented version of "object", then I'm not even sure what your question means.





When you do a #include %26lt;insertlibraryhere%26gt;, you are telling the compiler to look for a library matching the name you provided, and to include the functions contained within that library in the compiled code. So the answer to the 2nd alternative you provide ("are they in source code that must be loaded before the compiler runs") is yes. After the compiler runs, you will have an executable object file that does include the standard library functions.
Reply:C++ standard library is very good


try to use that
Reply:Taher is clueless, TOB has no idea what he is talking about, and sridhar is hard to understand, but I think he has it right.





So, the standard library is precompiled into binary. Whenever you compile your program, you do NOT recompile the standard library source. Whoever made your compiler has compiled the C/C++ runtime libraries and various library files for the different aspects of the standard library. So whenever your code uses something in those libraries, they get appropriately linked in.


No comments:

Post a Comment