許多在Linux下開發的C程序都需要頭文件unistd.h,但VC中沒有個頭文件,所以用VC編譯總是報錯。把下面的內容保存為unistd.h,放在visual stdio頭文件路徑下,可以解決這個問題。
我的路徑是:C:\Program Files (x86)\Microsoft VisualStudio\2017\Community\VC\Tools\MSVC\14.16.27023\include
/** This file is part of the Mingw32 package.
unistd.h maps (roughly) to io.h
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif /* _UNISTD_H */
由字面意思,unistd.h是unix std的意思,是POSIX標准定義的unix類系統定義符號常量的頭文件,包含了許多UNIX系統服務的函數原型,例如read函數、write函數和getpid函數。unistd.h在unix中類似於window中的windows.h。