If the source file that includes mqueue.h does no other UNIX I/O, O_RDWR is likely undeclared. Manually including fcntl.h fixes the compiler error. mq.c: In function 'openqueue': mq.c:41:35: error: 'O_RDWR' undeclared (first use in this function); did you mean '__SWR'? mq->handle = mq_open(mq->name, O_RDWR | O_CREAT, 0600, &att); Apologies if this is reported in the wrong place. I am not aware of having installed any package to obtain the message queueing service, so base system seems appropriate.
In case it matters, I use gcc, as installed by pkg install gcc
Strictly speaking, mqueue.h doesn't need any of the symbols defined in fcntl.h, so "need" wording is not entirely correct. OTOH, other systems seem to include fcntl.h in mqueue.h, and POSIX explicitly states that it's allowed: Inclusion of the <mqueue.h> header may make visible symbols defined in the headers <fcntl.h>, <signal.h>, and <time.h>.
Point taken about whether fcntl.h needs to be included or not. If not, the man page should show the required #include.
Perhaps the point is moot after all. I get errno 78 opening the queue now that I managed to compile the code. This is my trace of the failing open: mq_open /stxready error 78: Function not implemented Of course, it would help if I could know what exactly is not implemented. The man page does not offer any insight, nor does it mention the error ENOSYS, but of course, that could be a case of left hand and right hand. I do link with -lrt: gcc -o obj/FreeBSD.amd64/cdlist obj/FreeBSD.amd64/cdlist.o obj/FreeBSD.amd64/amix.o obj/FreeBSD.amd64/curs.o obj/FreeBSD.amd64/dirl.o obj/FreeBSD.amd64/dirpaint.o obj/FreeBSD.amd64/dmenu.o obj/FreeBSD.amd64/menu.o obj/FreeBSD.amd64/pl.o obj/FreeBSD.amd64/sched.o obj/FreeBSD.amd64/st.o obj/FreeBSD.amd64/cdlist_opts.o obj/FreeBSD.amd64/cdlist_enum.o jlinktime.c -L../playlist/obj/FreeBSD.amd64 -lXCurses -lmenu -lplaylist -lrt -lpthread -lasound -lj -L/home/john/lib -L/usr/local/lib
You need to have P1003_1B_MQUEUE in your kernel or load the mqueuefs module to enable support. Per the actual PR subject, we should project just include fcntl.h in mqueue.h. Header pollution seems not worth worrying about in this rarely used framework, especially since posix explicitly allows it.
Thanks. Loading the module fixed this for me. How would I have known that I need to load the kernel module?
(In reply to jphartmann from comment #6) man mq_open: NOTES ... Please see the mqueuefs(5) man page for instructions on loading the module or compiling the service into the kernel. man mqueuefs: SYNOPSIS To link into kernel: options P1003_1B_MQUEUE To load as a kernel loadable module: kldload mqueuefs
Thanks. I'll keep an eye open for those man 5 pages in future. As far as I am concerned, this issue can be closed.
(In reply to jphartmann from comment #8) You can close this bug yourself, since you are the original reporter