Sign in to follow this  
chaosgame

functions in includeed files in C++

Recommended Posts

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this