Solved

problems with "stdafx.h"

Posted on 2004-04-02
9
789 Views
Last Modified: 2008-02-01
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
Comment
Question by:NetwrkGuru
9 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 10740116
you should use
#ifdef _MSC_VER
#include "stdafx.h"
#endif
0
 
LVL 16

Expert Comment

by:nonubik
ID: 10740125
In fact it's the same :)
I think you have some unmatch #endif in your stdafx.h
Could you post it?
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10740179
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:NetwrkGuru
ID: 10740603
stdafx.h contains standart stuff after creating standart Win32 console application using VC++ wizard.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 10740625
please post it for check in order to get more help.
0
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 50 total points
ID: 10740982
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question