Sign in to follow this  
hotmailhacker

header files

Recommended Posts

Can you actually view the source code for header files such as iostream? If so, how? Also the same thing for built in functions like does main() actually have code built into it? Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by hotmailhacker
Can you actually view the source code for header files such as iostream? If so, how?

Only if the compiler provides it. In most cases (From what I have seen), it is within the standard library files which are pre-compiled.

Quote:
Original post by hotmailhacker
Also the same thing for built in functions like does main() actually have code built into it? Thanks.

main() does not. However, main() is called by the standard runtime library. The routine that calls main() is OS runtime specific. For Windows, it is usually mainCRTStartup(), which sets up the runtime (calls ctors, dtors, et al..)

Does main() itself have any code built into it? No.

Share this post


Link to post
Share on other sites
Quote:

Can you actually view the source code for header files such as iostream?

Absolutely. It's a header file, no different from any header you might write yourself.

Quote:

Only if the compiler provides it. In most cases (From what I have seen), it is within the standard library files which are pre-compiled.

Er, where have you been looking, and what have you been looking for? The standard library is almost entirely in header files (iostream included). Most of the stuff that exists in the runtime library is glue you rarely refer to explicitly. Anything you can include with the preprocessor must exist on the disk.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
Er, where have you been looking, and what have you been looking for? The standard library is almost entirely in header files (iostream included). Most of the stuff that exists in the runtime library is glue you rarely refer to explicitly. Anything you can include with the preprocessor must exist on the disk.

I was thinking he was referring to the source code to the standard library routines and classes; not just the header files (*.h). Alot of these routines are only declared within header files (*.h) but their implementations are within the standard library files.

Unless, I am mistaken?

Share this post


Link to post
Share on other sites
You're mistaken; most of the SC++L is entirely contained in the respective headers (they have to be, they're almost all templates).

The C standard library is a different story, although most compilers ship with the code.

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