• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • 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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
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
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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