Solved

problems with "stdafx.h"

Posted on 2004-04-02
9
777 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
Comment Utility
you should use
#ifdef _MSC_VER
#include "stdafx.h"
#endif
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

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

Expert Comment

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

Accepted Solution

by:
lakshman_ce earned 50 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now