| Summary: | KWayland can't build under strict POSIX systems: uid_t, gid_t undeclared | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] kwayland | Reporter: | A. Wilcox (awilfox) <awilfox> |
| Component: | general | Assignee: | Martin Flöser <mgraesslin> |
| Status: | RESOLVED FIXED | ||
| Severity: | major | CC: | elizabeth |
| Priority: | NOR | ||
| Version First Reported In: | 5.5.5 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | 1d531e997bfc1b0d30fdded7a01473570eda1de5 | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
| Attachments: | Add #include <sys/types.h> to clientconnection.h | ||
Created attachment 100229 [details]
Add #include <sys/types.h> to clientconnection.h
Is that also going to work with e.g. FreeBSD. The last time I had integrated a fix for more "strict" compilers, it broke on BSDs. So I'm sceptical ;-) I appreciate your scepticism, however, I can't really test this patch on FreeBSD... root@renton:~/kwayland-5.5.5/build # uname -a FreeBSD renton.foxkit.us 10.2-RELEASE-p9 FreeBSD 10.2-RELEASE-p9 #0: Thu Jan 14 01:32:46 UTC 2016 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 root@renton:~/kwayland-5.5.5/build # gmake [ 1%] Automatic moc for target KF5WaylandClient [ 1%] Built target KF5WaylandClient_automoc [ 1%] Building CXX object src/client/CMakeFiles/KF5WaylandClient.dir/fakeinput.cpp.o /root/kwayland-5.5.5/src/client/fakeinput.cpp:27:10: fatal error: 'linux/input.h' file not found #include <linux/input.h> ^ 1 error generated. If I may throw my hat into the ring, the synopsis for the manual page for getpid(2) on Linux and FreeBSD both say that you should include both sys/types.h and unistd.h. Also, regarding BSD compatibility, I think it goes without saying even a non-programmer can tell including a linux/*.h header makes your code inherently incompatible :p. Input injection (which I presume is the goal here) is probably possible on FreeBSD in some way, but I am not entirely sure how to achieve it without research. In any case, assuming there is legitimate desire for BSD support, I believe sys/types.h is required on BSD for uid_t and gid_t (though the manpage for getpgid(2) implies pid_t should be found in unistd.h on BSD). This was already fixed in May with 1d531e997bfc1b0d30fdded7a01473570eda1de5. |
uid_t, gid_t, and pid_t are defined in either <unistd.h> or <sys/types.h> under POSIX. This becomes relevant on strictly compliant systems such as the musl libc, and will continue to be a problem in the future as more C libraries clean up their headers. I have personally chosen to #include <sys/types.h> in clientconnection.h, but <unistd.h> is also valid. Reproducible: Always Steps to Reproduce: 1. Use a strictly conformant POSIX system (such as musl libc). 2. Attempt to build KWayland. Actual Results: /usr/src/kde-frameworks/kwayland-5.5.5/work/kwayland-5.5.5/src/server/clientconnection.h:100:5: error: ‘uid_t’ does not name a type uid_t userId() const; ^ /usr/src/kde-frameworks/kwayland-5.5.5/work/kwayland-5.5.5/src/server/clientconnection.h:109:5: error: ‘gid_t’ does not name a type gid_t groupId() const; ^ Expected Results: Successful build.