GNOME Bugzilla – Bug 783442
Cannot build gnome-screenshot with meson on FreeBSD because of -D_POSIX_C_SOURCE
Last modified: 2017-06-05 18:15:07 UTC
The use of -D_POSIX_C_SOURCE causes M_PI to be hidden: [1/2] Compiling c object 'src/gnome-screenshot@exe/screenshot-shadow.c.o' FAILED: src/gnome-screenshot@exe/screenshot-shadow.c.o clang '-Isrc/gnome-screenshot@exe' '-Isrc' '-I../../source/gnome-screenshot/src' '-I.' '-I../../source/gnome-screenshot/' '-I/home/lantw44/gnome/devinstall/include/glib-2.0' '-I/home/lantw44/gnome/devinstall/lib/glib-2.0/include' '-I/home/lantw44/gnome/devinstall/include/gtk-3.0' '-I/home/lantw44/gnome/devinstall/include/pango-1.0' '-I/usr/local/include/cairo' '-I/usr/local/include/pixman-1' '-I/usr/local/include/freetype2' '-I/usr/local/include/libdrm' '-I/usr/local/include/libpng16' '-I/home/lantw44/gnome/devinstall/include/harfbuzz' '-I/home/lantw44/gnome/devinstall/include/gdk-pixbuf-2.0' '-I/home/lantw44/gnome/devinstall/include/gio-unix-2.0/' '-I/home/lantw44/gnome/devinstall/include/atk-1.0' '-I/home/lantw44/gnome/devinstall/include/at-spi2-atk/2.0' '-I/home/lantw44/gnome/devinstall/include/at-spi-2.0' '-I/usr/local/include/dbus-1.0' '-I/usr/local/lib/dbus-1.0/include' '-Xclang' '-fcolor-diagnostics' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Wall' '-Winvalid-pch' '-std=c99' '-O2' '-g' '-D_POSIX_C_SOURCE' '-D_DEFAULT_SOURCE' '-march=corei7' '-B/home/lantw44/.local/bin' '-g3' '-O1' '-D_REENTRANT' '-pthread' '-D_THREAD_SAFE' '-DLOCALEDIR="/home/lantw44/gnome/devinstall/share/locale"' '-DGLIB_DISABLE_DEPRECATION_WARNINGS' '-DGDK_DISABLE_DEPRECATION_WARNINGS' '-MMD' '-MQ' 'src/gnome-screenshot@exe/screenshot-shadow.c.o' '-MF' 'src/gnome-screenshot@exe/screenshot-shadow.c.o.d' -o 'src/gnome-screenshot@exe/screenshot-shadow.c.o' -c ../../source/gnome-screenshot/src/screenshot-shadow.c ../../source/gnome-screenshot/src/screenshot-shadow.c:52:23: error: use of undeclared identifier 'M_PI' return ((1 / (2 * M_PI * r)) * ^ 1 error generated. M_PI is an X/Open system interface (XSI), but defining _POSIX_C_SOURCE without version on FreeBSD means an old version of POSIX with XSI disabled. This can be fixed by defining both _POSIX_C_SOURCE and _XOPEN_SOURCE with the latest versions available.
Created attachment 353196 [details] [review] build: Define both _POSIX_C_SOURCE and _XOPEN_SOURCE with versions FreeBSD libc assumes defining _POSIX_C_SOURCE without specifying a version means a pre-C89 environment with the oldest version of POSIX standard, IEEE Std 1003.1-1988. Defining _POSIX_C_SOURCE without defining _XOPEN_SOURCE also causes XSI to be disabled. However, M_PI constant is only available in XSI. Therefore, we have to define _XOPEN_SOURCE if we want to define _POSIX_C_SOURCE.
Emmanuele, what do you think?
Review of attachment 353196 [details] [review]: Looks good to me.
Attachment 353196 [details] pushed as 1089e4c - build: Define both _POSIX_C_SOURCE and _XOPEN_SOURCE with versions