SORU
4 Aralık 2008, PERŞEMBE


Unistd için bir değişiklik yoktur.Windows (Visual C) h?

Windows platformu (Visual C 8.0) Unıx için nispeten basit bir konsol program yazılı taşımaya çalışıyorum. Tüm kaynak dosyaları "unistd.yok.", h Kaldırma, misssing prototip hakkında şikayetler alıyorum'', 'rastgele',''. getopt srandom Rasgele işlevleri yerine biliyorum, Ve/-hack getopt bir uygulama bulabilirim eminim.

Ama diğerleri de aynı sorunla karşılaştığıma eminim. Benim soru şudur: "unistd.bir liman var h" Windows? En az birini içeren bu işlevleri olan yerel bir Windows uygulaması - borular veya bölmek istemiyorum.

EDİT:

Benim çok kendi "unistd.oluşturabilirim biliyorum h" olan şeyler için değişiklik içerir sınırlı olduğundan, özellikle bu durumda, gerekir. Ama ortak bir sorun gibi görünüyor, eğer birisi zaten işlevselliği daha büyük bir alt kümesi için yapılan iş var mı diye merak ettim.

Farklı derleyici veya ortama geçiş iş yerinde mümkün değil - Visual Studio ile kaldım.

CEVAP
5 Mayıs 2009, Salı


İnternette bir versiyonunu bulamadığımız için, buradan başlayalım.
Windows için en portu muhtemelen sadece tam Unıx dosya kümesini gerekir.
İşte başlangıç noktası. Tanımları gerektiği gibi ekleyin lütfen.

#ifndef _UNISTD_H
#define _UNISTD_H    1

/* This file intended to serve as a drop-in replacement for 
 *  unistd.h on Windows
 *  Please add functionality as neeeded 
 */

#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(). */

#define ssize_t int

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

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • boniver

    boniver

    17 NİSAN 2006
  • GFX Tutorials

    GFX Tutorial

    12 AĞUSTOS 2013
  • listedabive

    listedabive

    30 Ocak 2007