Trying to write a simple program involving processes for school, and I keep getting the above error, as well as the same implicit declaration error for pipe commands.
I'm:
- on Windows
- supposed to run POSIX related commands
- using VScode (if applicable)
- using MinGW for my headers and compiling
Here are my headers:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
here are just some of the commands being used:
int PtoC[2], CtoP[2];
pipe(PtoC);
pipe(CtoP);
int child_pid = fork();
if(child_pid < 0) {
exit(1);
}
The output when I try to compile with gcc:
In function 'main':
digits_sol.c:37:5: warning: implicit declaration of function 'pipe' [-Wimplicit-function-declaration]
pipe(PtoC);
^~~~
digits_sol.c:40:21: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
int child_pid = fork();
I've tried messing around with my .json settings file to include the unistd.h file
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\MinGW\\include**"
],
for some reason, my MinGW folder has a unistd.h in the MinGW\include directory, and also in the MinGW\include\sys directory
I'm not sure why my instructor wouldn't tell me how to run POSIX functions on windows, and I'd appreciate any help.