stdafx.h

I downloaded an example for a program but when I try to compile it I get an error that some headers are missing.
I have the file stdafx.h, but for all the headers that are included in this one (i.e stdafx.h) code::blocks tells me there's no such file or directory. Some of those headers are: afxwin.h, afxext.h, afxcmn.h,.....

I've seen this header in all visual studio projects so i'm wondering whether i'm just missing header files or is it something particular about stdafx.h that i'm doing wrong....
Don't start a new console project in VC++, that causes a lot of pain and suffering. Start a new "Blank" project instead.
I'm using Code::Blocks. The project I downloaded consist of a .cpp file and the header in subject. But stdafx.h is trying to #include a bunch of other headers that I don't have (afxwin.h, afxext.h, afxcmn.h,.....). Do I need stdafx.h if using codeblocks or is it only a VC++ header????

Yes, you don't need stdafx.h at all. Better include the required header directly. That's a precompiled header thing that nobody needs.
closed account (S6k9GNh0)
http://en.wikipedia.org/wiki/Precompiled_header#stdafx.h

It's only a VC++ header but that's actually beyond the point. How you have your program file layout is up to you. You don't actually need any headers (unless you are wanting the features they provide).
Is <iostream> included? If so, then stdafx is useleess and uneccesary. It's for those who use the console project in VC++.
GisleAune wrote:
It's for those who use the console project in VC++.
No it isn't
Still trying to make this work...... :(

so, here's the new problem (thanks for all the help by the way!):

the example i downloaded contains these files:
LAT.cpp
LAT.h
stdafx.cpp
stdafx.h

when i run LAT.cpp (main program file) gives me error for headers that stdafx.h is trying to include (afxwin.h, afxext.h, afxcmn.h,.....) "no such file or directory"

but when i comment #include "stdafx.h" out, I get this error:

1
2
3
#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif 


can anyone please tell me what's going on and how should i fix it?

million thanks
Last edited on
stdafx.h is trying to use stuff for VC++ to make your code worse. Since you don't need this bad-code-making-code in Code::Blocks, it can't find the bad-code-making-code in the first place, because Code::Blocks doesn't want to make your code bad.
You need to remove the dependencies on stdafx.h, like that error there is designed to force you to use the (horrid) stdafx.h. Just remove all that stuff and report back with what else complains.
Last edited on
Topic archived. No new replies allowed.