1

I am getting this error: unknown type name 'pid_t'. I think Build is failing due to commenting of a header file: unistd.h. Since windows does not support unistd.h, i comment #include <unistd> and the only use of this header is pid_t so I am looking forward to add pid_t definition manually in Visual Studio based on this answer.
any help?

Community
  • 1
  • 1
osyan
  • 1,784
  • 2
  • 25
  • 54
  • Do you compile on Windows or OS X or both? Do you *need* `pid_t` when you compile on Windows? – Martin R Oct 20 '12 at 08:45
  • @MartinR just on windows, and yes i need `pid_t` to compile on Windows – osyan Oct 20 '12 at 09:17
  • Can you provide more information where `pid_t` is needed? It is some Unix source that you want to compile on Windows? Do you also need `getpid()` ? – Martin R Oct 20 '12 at 09:40
  • 1
    it's a program under UNIX, and i'm trying to compile that on windows. i have corrected every error except this. it has used **pid_t** like this: `pid_t pidVirtuaCard=0;` and `if( (pidVirtuaCard=fork()) < 0 )`. And no i don't need to use `getpid()` anywhere. – osyan Oct 20 '12 at 09:53
  • Where is `fork()` defined? That is not a Windows function. – Martin R Oct 20 '12 at 09:55
  • ow. that's the next problem. Fork() is also defined in and there is no alternative of this header file for windows :/ – osyan Oct 20 '12 at 10:02

1 Answers1

2

Windows does not have a fork() function. You have the following options:

  • Rewrite the program to use CreateProcess(). But note that this is not a 1-to-1 replacement. It creates a new process that, unlike fork(), is not a copy of the calling process.

  • Use an environment that simulates the Unix API, for example Cygwin.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382