简体   繁体   English

将 C++ 转换为 VC++

[英]Convert c++ to VC++

We have working c++ code that works perfectly on Raspbian which is based on Debian.我们有可以在基于 Debian 的 Raspbian 上完美运行的 C++ 代码。 We want to convert it to VC++.我们想将其转换为 VC++。 But we see problem like how to get libraries:但是我们看到了诸如如何获取库之类的问题:

#include <string>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <iostream>
#include <cstdlib>
#include <sys/time.h>
#include <cstring>

#include <sys/ioctl.h>
#include <net/if.h>

using namespace std;

#include "base64.h"

#include <wiringPi.h>
#include <wiringPiSPI.h>

If I copy header files from Raspbian OS, would it be working with VC++(Windows 10 IoT) or it would create problems?如果我从 Raspbian OS 复制头文件,它会使用 VC++(Windows 10 IoT) 还是会产生问题?

Please advise, what is best way to deal with libraries used above?请指教,处理上面使用的库的最佳方法是什么?

Thanks谢谢

No, it'll not work if you copy files from raspbian.不,如果您从 raspbian 复制文件,它将不起作用。 You have to use library which is equivalent for windows.您必须使用与 Windows 等效的库。 For example, the equivalent of #include <sys/socket.h> in windows it is #include <winsock2.h> .例如, #include <sys/socket.h>在 Windows 中的等价物是#include <winsock2.h> You can use compile time condition code blocks.您可以使用编译时条件代码块。 For example -例如 -

#ifdef _WIN32 //true for all windows
#include <winsock2.h>
#else
#include <sys/socket.h>
#endif

You can also write other codes using this type of condition.您还可以使用这种类型的条件编写其他代码。 First of all you need to find out what are the alternatives of functions and libraries in windows you are using in debian.首先,您需要找出在 debian 中使用的 windows 中函数和库的替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM