sewenew/redis-plus-plus

[BUG] Not able to compile when redis-plus-plus is added as a package via vcpkg

vickylance opened this issue · 1 comments

Describe the bug

I have added hiredis and redis-plus-plus to vcpkg.json dependencies array.

{
    ...
    "dependencies": ["fmt", "spdlog", "openssl", "hiredis", "redis-plus-plus"]
}

After I saved the above file, vcpkg was able to install the "hiredis", "redis-plus-plus" packages. And cmake configuration and build ran successfully

And then I added to CMakeLists.txt as below,

...
find_package(hiredis CONFIG REQUIRED)
find_package(redis++ CONFIG REQUIRED)
...
target_link_libraries(${PROJECT_NAME}
    ...
    PRIVATE hiredis::hiredis
    PRIVATE PRIVATE redis++::redis++_static
)
...

And after I saved the above file cmake configuration and build ran successfully.

But then when I tried to use the redis-plus-plus in my project with the sample code below. Even just having the include statement gave the below error log when building.

...
#include <sw/redis++/redis++.h>

using namespace sw::redis;

namespace rl
{
    Main::Main()
    {
        try
        {
            auto redis = Redis("tcp://127.0.0.1:6379");
            redis.set("key", "val");
        }
        catch (const Error& e)
        {
            // Error handling.
        }
        ...

And then I tried to build the project I got the following error.

[main] Building folder: godot-roguelite 
[build] Starting build
[proc] Executing command: /opt/homebrew/bin/cmake --build /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug --parallel 12 --target roguelite
[build]   0% [0.024s] (0/2)  -Re-checking globbed directories...
[build]  50% [1.987s] (1/2)  -Building CXX object CMakeFiles/roguelite.dir/src/main.cpp.o
[build] FAILED: CMakeFiles/roguelite.dir/src/main.cpp.o 
[build] /usr/bin/clang++ -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DFMT_HEADER_ONLY=1 -DSPDLOG_FMT_EXTERNAL -Droguelite_EXPORTS -I/Users/vickylance/Projects/c++/godot-roguelite/src -isystem /Users/vickylance/Projects/c++/godot-roguelite/extern/godot-cpp/include -isystem /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/extern/godot-cpp/gen/include -isystem /Users/vickylance/Projects/c++/godot-roguelite/extern/godot-cpp/gdextension -isystem /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include -g -std=gnu++2b -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fPIC -fcolor-diagnostics -Wall -Wctor-dtor-privacy -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wwrite-strings -Wimplicit-fallthrough -Wno-ordered-compare-function-pointers -g -Wno-unused-value -Wno-ignored-attributes -Wno-unknown-attributes -fno-omit-frame-pointer -O0 -MD -MT CMakeFiles/roguelite.dir/src/main.cpp.o -MF CMakeFiles/roguelite.dir/src/main.cpp.o.d -o CMakeFiles/roguelite.dir/src/main.cpp.o -c /Users/vickylance/Projects/c++/godot-roguelite/src/main.cpp
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/src/main.cpp:8:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis++.h:20:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis.h:25:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/connection_pool.h:27:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/sentinel.h:26:
[build] /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/shards.h:70:15: error: too few arguments provided to function-like macro invocation
[build]     Slot slot() const {
[build]               ^
[build] /Users/vickylance/Projects/c++/godot-roguelite/src/util/bind.hpp:25:9: note: macro 'slot' defined here
[build] #define slot(slot_owner, slot_callback) \
[build]         ^
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/src/main.cpp:8:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis++.h:20:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis.h:25:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/connection_pool.h:27:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/sentinel.h:26:
[build] /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/shards.h:70:14: error: expected ';' at end of declaration list
[build]     Slot slot() const {
[build]              ^
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/src/main.cpp:8:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis++.h:21:
[build] In file included from /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis_cluster.h:1455:
[build] /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug/vcpkg_installed/arm64-osx/include/sw/redis++/redis_cluster.hpp:1357:41: error: no member named 'node' in 'sw::redis::AskError'
[build]             auto pool = _pool.fetch(err.node());
[build]                                     ~~~ ^
[build] 3 errors generated.
[build] ninja: build stopped: subcommand failed.
[proc] The command: /opt/homebrew/bin/cmake --build /Users/vickylance/Projects/c++/godot-roguelite/.out/build/clang-debug --parallel 12 --target roguelite exited with code: 1
[driver] Build completed: 00:00:02.261
[build] Build finished with exit code 1

Note: I am able to use hiredis fine and without any issue. And I am able to connect to redis and set a key value pair just using hiredis only redis-plus-plus is not working with vcpkg

To Reproduce

Minimal code has been provided above.

Expected behavior

I should be able to use the redis-plus-plus package when installed via vcpkg.

Environment:

  • OS: MacOS Sonoma 14.0 - M1 Pro
  • Compiler: Apple clang version 15.0.0 (clang-1500.0.40.1)
  • hiredis version: 1.2.0
  • redis-plus-plus version: 1.3.10

Additional context
Add any other context about the problem here.

Sorry the issue was that there was a macro defined as slot which was interfering with the Slot in redis-plus-plus library. Also I had hiredis as extra dependency.