G
Guest
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,
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,