Differences between C preprocessor #defines between autotools and meson
I just noticed the following warning when building with meson:
$ touch test/pdf-tagged-text.c&& ninja -C build-meson
ninja: Entering directory `build-meson'
[1/4] Compiling C object test/cairo-test-suite.p/pdf-tagged-text.c.o
../test/pdf-tagged-text.c: In function ‘check_contains_string’:
../test/pdf-tagged-text.c:381:9: warning: implicit declaration of function ‘memmem’; did you mean ‘memset’? [-Wimplicit-function-declaration]
381 | if (memmem(hay, size, needle, strlen(needle)))
| ^~~~~~
| memset
[4/4] Linking target test/cairo-test-suite
Thinking "ah, that's an easy fix; just a missing include", I checked man memmem
and learned:
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
Guess what, the right header is already included! The difference comes from this:
$ grep _GNU_SOURCE build-auto/config.h build-meson/config.h
build-auto/config.h:#ifndef _GNU_SOURCE
build-auto/config.h:# define _GNU_SOURCE 1
There are quite a number of other differences between the two headers. The grep
in the following command removes comments, sed
is used to remove empty lines. That makes the files easier to compare. Not all of the differences are relevant, but still, I guess someone should go through these and check their relevance. (For example, CAIRO_HAS_INTERPRETER
and CAIRO_HAS_TEST_SURFACES
are never #ifdef
d and only exist for automake reasons.)
$ diff -Nurp <(grep -vE '/\*|\*/' build-auto/config.h | sed '/^$/d') <(sed '/^$/d' build-meson/config.h)
--- /proc/self/fd/11 2021-02-07 10:48:31.530353730 +0100
+++ /proc/self/fd/18 2021-02-07 10:48:31.530353730 +0100
@@ -1,19 +1,20 @@
+/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
+#pragma once
#define CAIRO_CAN_TEST_PDF_SURFACE 1
#define CAIRO_HAS_DLSYM 1
-#define CAIRO_HAS_INTERPRETER 1
#define CAIRO_HAS_PTHREAD 1
#define CAIRO_HAS_REAL_PTHREAD 1
#define CAIRO_HAS_SPECTRE 1
-#define CAIRO_HAS_TEST_SURFACES 1
#define CAIRO_HAS_TRACE 1
#define HAS_PIXMAN_GLYPHS 1
#define HAVE_ALARM 1
-#define HAVE_BUILTIN_RETURN_ADDRESS 1
#define HAVE_BYTESWAP_H 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_CTIME_R 1
#define HAVE_CXX11_ATOMIC_PRIMITIVES 1
-#define HAVE_DLFCN_H 1
#define HAVE_DRAND48 1
#define HAVE_FCFINI 1
#define HAVE_FCINIT 1
@@ -36,24 +37,18 @@
#define HAVE_GMTIME_R 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIBGEN_H 1
-#define HAVE_LIBRT 1
#define HAVE_LINK 1
#define HAVE_LOCALTIME_R 1
-#define HAVE_MEMORY_H 1
#define HAVE_MKDIR 2
#define HAVE_MMAP 1
#define HAVE_NEWLOCALE 1
#define HAVE_POLL_H 1
-#define HAVE_POPPLER_PAGE_RENDER 1
#define HAVE_RAISE 1
#define HAVE_SCHED_GETAFFINITY 1
#define HAVE_SCHED_H 1
#define HAVE_SETJMP_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
#define HAVE_STRNDUP 1
#define HAVE_STRTOD_L 1
#define HAVE_SYS_IOCTL_H 1
@@ -61,14 +56,11 @@
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_TIME_H 1
-#define HAVE_TYPEOF 1
#define HAVE_UINT64_T 1
#define HAVE_UNISTD_H 1
-#define HAVE_VALGRIND 1
#define HAVE_WAITPID 1
#define HAVE_X11_EXTENSIONS_SHMPROTO_H 1
#define HAVE_X11_EXTENSIONS_SHMSTR_H 1
@@ -80,53 +72,8 @@
#define HAVE_ZLIB 1
#define HAVE___UINT128_T 1
#define IPC_RMID_DEFERRED_RELEASE 1
-#define LT_OBJDIR ".libs/"
-#define PACKAGE_BUGREPORT "https://gitlab.freedesktop.org/cairo/cairo/-/issues"
-#define PACKAGE_NAME USE_cairo_INSTEAD
-#define PACKAGE_STRING USE_cairo_version_OR_cairo_version_string_INSTEAD
-#define PACKAGE_TARNAME USE_cairo_INSTEAD
-#define PACKAGE_URL "https://cairographics.org/"
-#define PACKAGE_VERSION USE_cairo_version_OR_cairo_version_string_INSTEAD
-#define SHARED_LIB_EXT "so"
#define SIZEOF_INT 4
#define SIZEOF_LONG 8
#define SIZEOF_LONG_LONG 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_VOID_P 8
-#define STDC_HEADERS 1
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-#define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# endif
-#endif
-#ifdef __APPLE_CC__
-#ifdef __BIG_ENDIAN__
-#define WORDS_BIGENDIAN 1
-#define FLOAT_WORDS_BIGENDIAN 1
-#else
-#endif
-#endif
-#ifndef _DARWIN_USE_64_BIT_INODE
-# define _DARWIN_USE_64_BIT_INODE 1
-#endif
-#ifndef __cplusplus
-#endif