I'm trying to write a program that compiles in Borland C++ and Visual C++. To do this, I add #ifdef _MSC_VER
to include the stdafx.h file when the source is compiled under VS. The code compiles and executes OK in Borland C++, but in VS, it fails:
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;
}
How I can fix this error?