Windows(Visual C)에 해당하는 unistd.h가 있습니까?
Windows(Visual C)에 unistd.h를 대체할 수 있는 것이 있나요?
유닉스용으로 작성된 비교적 간단한 콘솔 프로그램을 윈도우 플랫폼(Visual C 8.0)으로 이식하기 위해 모든 소스 파일에는 윈도우에는 없는 "unistd.h"가 포함되어 있다. 이를 제거한 후 시스템은 'srandom', 'random' 및 'getopt'에 대한 프로토타입을 찾을 수 없다고 불평합니다.
random 함수를 대체할 수 있다는 것을 이해하고 getopt 구현을 찾거나 얻을 수 있다고 확신합니다.
하지만 다른 사람들도 같은 어려움을 겪었다고 생각합니다. 내 질문은: Windows에 "unistd.h" 포트가 있습니까? 최소한 Windows 기본 구현이 포함된 기능은 포함되어야 하며 파이핑이나 분기가 필요하지 않습니다.
편집:
필요한 대체 항목이 포함된 자체 "unistd.h"를 만들 수 있다는 것을 알고 있습니다. 특히 이 경우에는 제한되어 있기 때문입니다. 수집. 그런데 흔한 문제인 것 같아서 좀 더 폭넓은 기능을 위해 이렇게 하신 분이 계신지 궁금합니다.
작업 중 다른 컴파일러나 환경으로의 전환은 불가능합니다. Visual Studio만 사용할 수 있습니다.
대안:
인터넷에서 버전을 찾을 수 없으므로 여기서 시작해 보겠습니다. Windows로 이식된 대부분의 파일에는 전체 Unix 파일의 하위 집합만 필요할 것입니다.
이것이 출발점입니다. 필요에 따라 정의를 추가하세요.
#ifndef _UNISTD_H #define _UNISTD_H 1 /* This is intended as a drop-in replacement for unistd.h on Windows. * Please add functionality as needed. * https://stackoverflow.com/a/826027/1202830 */ #include <stdlib.h> #include <io.h> #include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */ #include <process.h> /* for getpid() and the exec..() family */ #include <direct.h> /* for _getcwd() and _chdir() */ #define srandom srand #define random rand /* Values for the second argument to access. These may be OR'd together. */ #define R_OK 4 /* Test for read permission. */ #define W_OK 2 /* Test for write permission. */ //#define X_OK 1 /* execute permission - unsupported in windows*/ #define F_OK 0 /* Test for existence. */ #define access _access #define dup2 _dup2 #define execve _execve #define ftruncate _chsize #define unlink _unlink #define fileno _fileno #define getcwd _getcwd #define chdir _chdir #define isatty _isatty #define lseek _lseek /* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ #ifdef _WIN64 #define ssize_t __int64 #else #define ssize_t long #endif #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 /* should be in some equivalent to <sys/types.h> */ typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; #endif /* unistd.h */
위 내용은 Windows(Visual C)에 해당하는 unistd.h가 있습니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











C 언어 함수에 의해 반환 된 값 유형은 무엇입니까? 반환 값을 결정하는 것은 무엇입니까?

STL (정렬, 찾기, 변환 등)의 알고리즘을 효율적으로 사용하려면 어떻게합니까?
