• Advertisement
Sign in to follow this  

functions in includeed files in C++

This topic is 4651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When you include a file in C++ such as iostream, it contains the function definitions. Where are the functions?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Tera_Dragon
In the source (.c .cc .cpp) files. Like your code should be too ;)


He's asking where the stream functions are, not his own functions.

I believe they are in the .lib(or .a) files that you link with or a DLL. Most compilers will link with the standard libraries without you having to say so.

Share this post


Link to post
Share on other sites
Quote:
Original post by Scet
Quote:
Original post by Tera_Dragon
In the source (.c .cc .cpp) files. Like your code should be too ;)


He's asking where the stream functions are, not his own functions.

I believe they are in the .lib(or .a) files that you link with or a DLL. Most compilers will link with the standard libraries without you having to say so.


Ah ok, missed that. Sorry about that, Scet is right.

Share this post


Link to post
Share on other sites
Nope, .lib (or .a) is used by the linker to create the executable by "copying" in the functions and symbols it needs. DLLs (or .so) are linked when the application is run (thus the name Dynamic Runtime Library).

IIRC the standard library source ships with VisualStudio.

Cheers,
Drag0n

Share this post


Link to post
Share on other sites
thanks
How does the linker know to include these files?
and is there code in these files?

Share this post


Link to post
Share on other sites
Quote:
Original post by chaosgame
How does the linker know to include these files?


Any file you include, header or not, becomes part of the file you included it into, just as if you had cut and pasted it.

Quote:
and is there code in these files?


Yes. Mostly class definitions with inline functions.

Share this post


Link to post
Share on other sites
Normally you would have to add them to project options however any modern compiler automatically includes the standard library .lib files(for things like iostream).

They don't contain C++ code. Instead they contain precompiled code(machine code/debug symbols) that the linker adds to your executable(.exe) to form the program.

Basically the function definitions are in the plain text headers so the compiler can see mistakes before linking and the libraries contain the actual machine code(or something close to it).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement