我正在尝试编写一个在Borland C和Visual C中编译的程序.为此,我添加#ifdef _MSC_VER以在VS下编译源时包含stdafx.h文件.代码在Borland C中编译并执行OK,但在VS中,它失败了:
error C1020: unexpected #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; }