Closed mirlos-pt closed 3 years ago
Thanks for catching it. As tkrzw::PAGE_SIZE is an external name, it a part of the public API. So, I want to keep the name if possible. Do you know where the PAGE_SIZE macro comes from?
Maybe, the underlying libc library "musl" is the cause. https://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/limits.h
Adding -DNPAGE_SIZE to CPPFLAGS in Makefile could solve this issue. Could you try it?
It comes from the musl C library indeed.
/usr/include # grep -C 5 PAGE_SIZE limits.h
#endif
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
#ifdef PAGESIZE
#define PAGE_SIZE PAGESIZE
#endif
#define NZERO 20
#define NL_LANGMAX 32
#endif
/usr/include # apk info --who-owns limits.h
/usr/include/limits.h is owned by musl-dev-1.2.2-r0
The CPPFLAGS change is ineffective:
/tkrzw # make
g++ -c -DNPAGE_SIZE -I. -I/usr/local/include -DNDEBUG -D_GNU_SOURCE=1 -D_ISOC99_SOURCE=1 -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D__EXTENSIONS__ -D_TKRZW_PREFIX
="\"/usr/local\"" -D_TKRZW_INCLUDEDIR="\"/usr/local/include\"" -D_TKRZW_LIBDIR="\"/usr/local/lib\"" -D_TKRZW_BINDIR="\"/usr/local/bin\"" -D_TKRZW_LIBEXECDIR="\"/usr/local/libexec\"" -
D_TKRZW_APPINC="\"-I/usr/local/include\"" -D_TKRZW_APPLIBS="\"-L/usr/local/lib -ltkrzw -lstdc++ -lrt -lpthread -lm -lc \"" -D_TKRZW_PKG_VERSION="\"0.9.3\"" -D_TKRZW_LIB_VERSION="\"0.3
.0\"" -MMD -g -O2 -std=c++17 -pthread -fPIC -fsigned-char tkrzw_lib_common.cc
In file included from /usr/include/limits.h:40,
from /usr/include/sys/param.h:33,
from tkrzw_sys_config.h:126,
from tkrzw_lib_common.cc:15:
tkrzw_lib_common.cc:19:15: error: expected unqualified-id before numeric constant
19 | const int32_t PAGE_SIZE = sysconf(_SC_PAGESIZE);
| ^~~~~~~~~
make: *** [Makefile:560: tkrzw_lib_common.o] Error 1
Undefining in the header above makes it compile too. If clients don't include the header, then that might be an ok solution.
diff --git a/tkrzw_sys_config.h b/tkrzw_sys_config.h
index dbde3a4..2bd5121 100644
--- a/tkrzw_sys_config.h
+++ b/tkrzw_sys_config.h
@@ -133,6 +133,11 @@ extern "C" {
#include <sys/resource.h>
#include <fcntl.h>
#include <dirent.h>
+
+#ifdef PAGE_SIZE
+#undef PAGE_SIZE
+#endif
+
} // extern "C"
namespace tkrzw {
I see. Then, I'll undef macros which can conflicts the constants defined in tkrzw_sys_config.h.
I committed the update.
There is a build failure when compiling on an alpine (python, but that's not relevant) image.
To reproduce, prepare an image for interactive use:
Inside the container:
The build proceeds, and make test check succeeds, after: