I'm working on a project for a class regarding shared memory and pipes between child and parent processes and would like to learn more about some issues I'm having so I can fix my code on my own and learn more about the project.
I found code here courtesy of 'WhozCraig' which demonstrates a simple usage of pipes between child and parent processes to send and receive integers.
Were I to save this as, say, 'test.c' and compile it as simple as:
gcc test.c
There are no problems. The code compiles and runs just fine and prints out what it should.
For my project, my code must be compiled with special flags and options. And if I try to compile the code 'WhozCraig' so nicely wrote up, it compiles just fine with a bit of editing (removing the command line arguments which are declared but unused and including a header file for wait()
to not be declared implicitly).
However, when I run the code, nothing prints.
Here's how I have to compile my code, and how I compile the example code (which causes the issue of no print outs):
gcc -std=c99 -Wall -Wextra -D_XOPEN_SOURCE=700 -o test test.c -lrt
I would like to know more about the flags we're giving to gcc, to see why both my main program and this example code does not work with it.
In particular I'm not sure what the flag D_XOPEN_SOURCE=700
does.
I know -Wall
and -Wextra
print out more warning messages, and -lrt
is for ensuring shared memory works well however, just confused about that middle bit, although any extra insight into the other flags will certainly be appreciated if it pertains to my problem.