• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 829
  • Last Modified:

problems with "stdafx.h"

Hi,

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

mytest.cpp

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

int main()
{
....
}

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

"fatal error C1019: unexpected #endif"

What should I do for condition including "stdafx.h" ???
0
NetwrkGuru
Asked:
NetwrkGuru
1 Solution
 
nonubikCommented:
you should use
#ifdef _MSC_VER
#include "stdafx.h"
#endif
0
 
nonubikCommented:
In fact it's the same :)
I think you have some unmatch #endif in your stdafx.h
Could you post it?
0
 
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
NetwrkGuruAuthor Commented:
stdafx.h contains standart stuff after creating standart Win32 console application using VC++ wizard.
0
 
nonubikCommented:
please post it for check in order to get more help.
0
 
lakshman_ceCommented:
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.

-Lakshman
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now