Linux C++代码移植到Windows要解决的问题

1、新建一个Win32项目,将所有源文件复制到项目文件夹中,并添加到工程中。

2、直接编译会出现错误:fatal error C1010: unexpected end of file while looking for precompiled header directive

  致命错误C1010:在寻找预编译指示头文件时,文件未预期结束。
  就是没有找到预编译指示信息的头文件。
  问题一般发生在:通过添加文件的方式,添加了一些cpp文件到一个MFC的程序,但该cpp文件并不是MFC,而是标准的C++。 
  解决方案1: 右键单击项目工程中的cpp文件,在菜单Project->Settings->C/C++->Precompile Header,设置为第一项:Not using precompile headers。
  解决方案2: 在.cpp文件开头添加包含文件stdafx.h。 #include"stdafx.h"

3、平台相关头文件宏定义

#ifdef WIN32
#include <time.h> //win32下的头文件
#endif

#ifdef UNIX
#include <sys/time.h>  //Linux下的头文件
#endif

原文地址:https://www.cnblogs.com/javawebsoa/p/3080632.html