Skip to content

Fix PAGESIZE to compile on systems where it's already defined as a macro.#50

Open
creationix wants to merge 1 commit into
Kong:mainfrom
creationix:patch-1
Open

Fix PAGESIZE to compile on systems where it's already defined as a macro.#50
creationix wants to merge 1 commit into
Kong:mainfrom
creationix:patch-1

Conversation

@creationix
Copy link
Copy Markdown

On some systems PAGESIZE is a macro that expands to a numeric constant. This causes a syntax error.

/tmp/lua-resty-simdjson-1.2.0 # make libsimdjson_ffi.o
c++ -ggdb -O3 -DNDEBUG -o libsimdjson_ffi.o  -c -fPIC src/simdjson_ffi.cpp
In file included from /usr/include/limits.h:40,
                 from /usr/include/c++/13.2.1/climits:42,
                 from src/simdjson.h:136,
                 from src/simdjson_ffi.cpp:1:
src/simdjson_ffi.cpp:9:13: error: expected unqualified-id before numeric constant
    9 | static long PAGESIZE = 0;
      |             ^~~~~~~~
src/simdjson_ffi.cpp: In function 'bool need_allocation(const char*, std::size_t)':
src/simdjson_ffi.cpp:20:9: error: lvalue required as left operand of assignment
   20 |         PAGESIZE = getpagesize();
      |         ^~~~~~~~
make: *** [Makefile:40: libsimdjson_ffi.o] Error 1

This PR fixes this by using ifndef to only try to initialize and set it if the macro doesn't exist.

On some systems `PAGESIZE` is a macro that expands to a numeric constant.  This causes a syntax error.

This PR fixes this by using `ifndef` to only try to initialize and set it if the macro doesn't exist.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 20, 2025

CLA assistant check
All committers have signed the CLA.

@creationix creationix changed the title Fix PAGESIZE to compile on systems where it's already defined. Fix PAGESIZE to compile on systems where it's already defined as a macro. Aug 20, 2025
@creationix creationix marked this pull request as draft August 20, 2025 18:06
@creationix creationix marked this pull request as ready for review August 20, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants