我正在尝试编写一个可以在Borland C++和Visual C++中编译的程序。为此,在源代码在VS下编译时,我添加了
我该如何修复这个错误?
#ifdef _MSC_VER
来包含stdafx.h文件。该代码可以在Borland C++中编译并执行正常,但在VS下会失败:
错误C1020:意外的#endif
#ifdef _MSC_VER //I'm in VS
#include "stdafx.h"
#endif //this line doesn't compile in VS
#ifdef __BORLANDC__ //I'm in Borland
#pragma hdrstop
#pragma argsused
#endif
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello" << std::endl;
std::cin.get();
return 0;
}
我该如何修复这个错误?