Question About Headers and Compiling

The last time I compiled a program and used it on a computer other than the one I compiled it on, it ran errors over what I am guessing was a missing header file. When I did it before, which was a while ago, I might have used the precompile header stdafx.h.

So my question is, do compilers automatically compile the headers into the too?

If not, how do I incorporate to do so.

Thank you for reading.
Last edited on
headers usually don't get compiled, stdafx.h is a VC++ stupid thing.
If you start from an "Empty Project" you don't need it
Library references can be found here: http://cplusplus.com/reference/clibrary/
Way to get around this is not to use the precompiled header.

Just make "Blank projects" in VSC++ it will make your life a lot easier.

So my question is, do compilers automatically compile the headers into the too?


yes, however that header is designed so you put all your header declarations in it. Basically to cut down on code in your main program or something. So if you had of taken the header with you when you compiled on the other PC, it may of worked... Should have.

Better to just not use it, It's a pointless Microsoft only thing. Most other IDE's don't do it.

edit: damn me and my slow typing
Also I don't mean to say it compiles with the program, however if you had all your includes in it, but tried to compile without it you would get errors, but assuming you had all the header files in question they should and could have worked with the compiled .cpp
Last edited on
Thanks Bazzy and Kevin, and gcampton

I've stopped using stdafx anyways, it caused problems with my compiler.

I'm going to try using my programs on another computer once I get a chance.
Last edited on
it doesn't compile the code exactly, it takes the definitions listed which is added to the preproccessor stage I believe, anyway someone will correct me if I'm wrong, and hopefully elaborate a little.
Last edited on
Topic archived. No new replies allowed.