c - Why does my compiler not accept fork(), despite my inclusion of <unistd.h>? -
here's code (created test fork()):
#include <stdio.h> #include <ctype.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include <unistd.h> int main() { int pid; pid=fork(); if (pid==0) { printf("i child\n"); printf("my pid=%d\n", getpid()); } return 0; }
i following warnings:
warning: implicit declaration of function 'fork' undefined reference 'fork'
what wrong it?
unistd.h
, fork
part of posix standard. aren't available on windows (text.exe
in gcc command hints that's you're not on *nix).
it looks you're using gcc part of mingw, provide unistd.h
header not implement functions fork
. cygwin does provide implementations of functions fork
.
however, since homework should have instructions on how obtain working environment.
Comments
Post a Comment