簡體   English   中英

將 C++ 轉換為 VC++

[英]Convert c++ to VC++

我們有可以在基於 Debian 的 Raspbian 上完美運行的 C++ 代碼。 我們想將其轉換為 VC++。 但是我們看到了諸如如何獲取庫之類的問題:

#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>

如果我從 Raspbian OS 復制頭文件,它會使用 VC++(Windows 10 IoT) 還是會產生問題?

請指教,處理上面使用的庫的最佳方法是什么?

謝謝

不,如果您從 raspbian 復制文件,它將不起作用。 您必須使用與 Windows 等效的庫。 例如, #include <sys/socket.h>在 Windows 中的等價物是#include <winsock2.h> 您可以使用編譯時條件代碼塊。 例如 -

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

您還可以使用這種類型的條件編寫其他代碼。 首先,您需要找出在 debian 中使用的 windows 中函數和庫的替代方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM