By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

Fatal Error C1019. No error if it is compiled in VC++ 6.0

P: n/a
Hi,

I have a C++ source file (mymessage.cpp), it is used by two different
platforms. PC and VxWorks.

The file has a header section to include header files depending on which
platform it is compiled. The code is like this:

#ifndef _VxWORKS
#include "stdafx.h"
#include "PCclass.h"
#else // Error pointed line
#include "noPCclass.h"
#endif

.....

where stdafx.h is a precompiled header file on PC side. PCclass.h is the
header file needs to be included in PC side, and noPCclass.h is the header
file needs to be included in VxWorks side.

When I compile this file mymessage.cpp in Visual C++ .Net, I got compile
error C1019. But the same file is compiled in Visual C++ 6.0, and I got no
error.

I did some investigation, I found that actually, the error is caused by
precompiled header file stdafx.h. If I move #incldue "stdafx.h" outside of
#idndef, #else block. like following,
#include "stdafx.h"

#ifndef _VxWORKS
#include "PCclass.h"
#else
#include "noPCclass.h"
#endif

then error goes away. But that means I need to put stdafx.h in VxWorks
enviroment. I don't want to do this, since stdafx.h is Microsoft stuff.
Any one has any better solution?

Thanks,

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Cynthia" <Cy*****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
Hi, Hi.
I have a C++ source file (mymessage.cpp), it is used by two different
platforms. PC and VxWorks.

The file has a header section to include header files depending on which
platform it is compiled. The code is like this:

#ifndef _VxWORKS
#include "stdafx.h"
#include "PCclass.h"
#else // Error pointed line
#include "noPCclass.h"
#endif

....

where stdafx.h is a precompiled header file on PC side. PCclass.h is the
header file needs to be included in PC side, and noPCclass.h is the header
file needs to be included in VxWorks side.

When I compile this file mymessage.cpp in Visual C++ .Net, I got compile
error C1019. But the same file is compiled in Visual C++ 6.0, and I got no
error.
That was (good or bad) luck, I think.
I did some investigation, I found that actually, the error is caused by
precompiled header file stdafx.h.
More accurately, it was caused by imbalanced preprocessor
directives that result from how precompilation is effected.
You would see the same effect regardless of the content
of stdafx.h.
If I move #incldue "stdafx.h" outside of
#idndef, #else block. like following,
#include "stdafx.h"

#ifndef _VxWORKS
#include "PCclass.h"
#else
#include "noPCclass.h"
#endif

then error goes away. But that means I need to put stdafx.h in VxWorks
enviroment. I don't want to do this, since stdafx.h is Microsoft stuff.
Any one has any better solution?
There is nothing magic about the name "stdafx.h" other than
certain Microsoft tool wizards having picked it for you.

One improvement on the situation would be to put the
conditional compilation directives within stdafx.h itself,
making it do nothing (or whatever you like in the way
of a standard #include sequence) for non-VC builds.
And if you dislike the name stdafx.h, you are free to
change it. Perhaps "std_incs.h", indicating that it is
not dedicated to the VC build or AFX stuff.
Thanks,

You're welcome.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.