After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783442 - Cannot build gnome-screenshot with meson on FreeBSD because of -D_POSIX_C_SOURCE
Cannot build gnome-screenshot with meson on FreeBSD because of -D_POSIX_C_SOURCE
Status: RESOLVED FIXED
Product: gnome-screenshot
Classification: Core
Component: general
git master
Other FreeBSD
: Normal normal
: ---
Assigned To: gnome-screenshot-maint
gnome-screenshot-maint
Depends on:
Blocks:
 
 
Reported: 2017-06-05 16:10 UTC by Ting-Wei Lan
Modified: 2017-06-05 18:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
build: Define both _POSIX_C_SOURCE and _XOPEN_SOURCE with versions (1.15 KB, patch)
2017-06-05 16:16 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2017-06-05 16:10:34 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.
Comment 1 Ting-Wei Lan 2017-06-05 16:16:52 UTC
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.
Comment 2 Cosimo Cecchi 2017-06-05 16:50:56 UTC
Emmanuele, what do you think?
Comment 3 Emmanuele Bassi (:ebassi) 2017-06-05 17:27:25 UTC
Review of attachment 353196 [details] [review]:

Looks good to me.
Comment 4 Ting-Wei Lan 2017-06-05 18:15:04 UTC
Attachment 353196 [details] pushed as 1089e4c - build: Define both _POSIX_C_SOURCE and _XOPEN_SOURCE with versions