Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Building rapidjson: cannot assign to non-static data member 'length' #867

Closed
graphemecluster opened this issue May 21, 2024 · 3 comments

Comments

@graphemecluster
Copy link

I got an error described exactly the same as in Tencent/rapidjson#718, which is introduced in Tencent/rapidjson@be5a886 and fixed in Tencent/rapidjson@3b2441b, while building OpenCC with Emscripten in CI today (but not yesterday, I don’t know why). The error occurs regardless of platform (in all Windows, macOS, Ubuntu and Docker). I have fixed the issue myself by applying the patch.

So please be reminded to update rapidjson. Thank you!

Log from GitHub Actions
Building opencc
configure: cmake librime/deps/opencc -B build/opencc -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_FIND_ROOT_PATH:PATH=D:\a\TypeDuck-Web\TypeDuck-Web/build/sysroot/usr -DSHARE_INSTALL_PREFIX:PATH=/usr/share/rime-data/ -DENABLE_DARTS:BOOL=OFF -DUSE_SYSTEM_MARISA:BOOL=ON -DCMAKE_TOOLCHAIN_FILE=D:\a\_temp\6892e8c0-2712-40df-80fc-c7529c324ea4\emsdk-main\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=D:/a/_temp/6892e8c0-2712-40df-80fc-c7529c324ea4/emsdk-main/node/16.20.0_64bit/bin/node.exe
-- libmarisa found: D:/a/TypeDuck-Web/TypeDuck-Web/build/sysroot/usr/lib/libmarisa.a
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done (5.9s)
-- Generating done (0.0s)
-- Build files have been written to: D:/a/TypeDuck-Web/TypeDuck-Web/build/opencc
[1/19] Building CXX object src/CMakeFiles/libopencc.dir/ConversionChain.cpp.o
[2/19] Building CXX object src/CMakeFiles/libopencc.dir/Converter.cpp.o
[3/19] Building CXX object src/CMakeFiles/libopencc.dir/DictConverter.cpp.o
[4/19] Building CXX object src/CMakeFiles/libopencc.dir/Config.cpp.o
FAILED: src/CMakeFiles/libopencc.dir/Config.cpp.o 
D:\a\_temp\6892e8c0-2712-40df-80fc-c7529c324ea4\emsdk-main\upstream\emscripten\em++.bat -DLOCALEDIR=\"/usr/share/rime-data/locale/\" -DOpencc_BUILT_AS_STATIC -DPACKAGE_NAME=\"opencc\" -DPKGDATADIR=\"/usr/share/rime-data/opencc/\" -DVERSION=\"1.1.7\" -ID:/a/TypeDuck-Web/TypeDuck-Web/build/opencc/src -ID:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src -ID:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/../deps/rapidjson-1.1.0 -ID:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/../deps/tclap-1.2.2 -fexceptions -DBOOST_DISABLE_CURRENT_LOCATION -O3 -DNDEBUG -fPIC   -ffile-prefix-map=D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc=. -I"D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/../../../build/sysroot/usr/include" -std=c++14 -Wall -MD -MT src/CMakeFiles/libopencc.dir/Config.cpp.o -MF src\CMakeFiles\libopencc.dir\Config.cpp.o.d -o src/CMakeFiles/libopencc.dir/Config.cpp.o -c D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/Config.cpp
In file included from D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/Config.cpp:23:
D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/../deps/rapidjson-1.1.0\rapidjson/document.h:319:82: error: cannot assign to non-static data member 'length' with const-qualified type 'const SizeType' (aka 'const unsigned int')
  319 |     GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
      |                                                                           ~~~~~~ ^
D:/a/TypeDuck-Web/TypeDuck-Web/librime/deps/opencc/src/../deps/rapidjson-1.1.0\rapidjson/document.h:325:20: note: non-static data member 'length' declared const here
  325 |     const SizeType length; //!< length of the string (excluding the trailing NULL terminator)

      |     ~~~~~~~~~~~~~~~^~~~~~

1 error generated.
@BYVoid
Copy link
Owner

BYVoid commented Jul 26, 2024

OpenCC bundles the latest version: https://github.com/BYVoid/OpenCC/tree/master/deps/rapidjson-1.1.0

Is there a later version?

@graphemecluster
Copy link
Author

Unfortunately I don’t think any versions newer than 1.1.0 in 2016 are officially released, despite the repo being in active development. So I think there are 3 options available: 1. Upgrade to an unstable commit version; 2. Apply the mentioned patch in this repo; or 3. Ignore this issue for the time being.

@BYVoid
Copy link
Owner

BYVoid commented Jul 30, 2024

Done. e1f3e6b

Thank you!

@BYVoid BYVoid closed this as completed Jul 30, 2024
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

No branches or pull requests

2 participants