problems with "stdafx.h"


I'm developing cross-platform application using C++.
I want to include "stdafx.h" header file only when compiling in Microsoft Visual C++.


#if defined (_MSC_VER)
#include "stdafx.h"

int main()

When compiling using Microsoft Visual C++, I get:

"fatal error C1019: unexpected #endif"

What should I do for condition including "stdafx.h" ???
Who is Participating?
lakshman_ceConnect With a Mentor Commented:
In Visual studio,
select your proeject->go to settings->C++->precompiled headers (select from drop down)
give the option Not using precompiled headers. This will enable you to compile in VC++ without stdafx.h and also the same code can be used for compiling on AIX or anywhere else.

you should use
#ifdef _MSC_VER
#include "stdafx.h"
In fact it's the same :)
I think you have some unmatch #endif in your stdafx.h
Could you post it?
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Karl Heinz KremerCommented:
What's in your stdafx.h? It's possible that the unmatched #if is in one of your include files, and not the .cpp file.
NetwrkGuruAuthor Commented:
stdafx.h contains standart stuff after creating standart Win32 console application using VC++ wizard.
please post it for check in order to get more help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.