错误:当我编译 c++ 项目时,在“)”之前预期 unqualified-id

error: expected unqualified-id before ‘)’ when I compile a c++ project

提问人:Adriano Kramer 提问时间:11/15/2023 最后编辑:jsotolaAdriano Kramer 更新时间:11/16/2023 访问量:46

问:

尝试编译cpp钩子项目时遇到此错误

/root/lib-173/hook.cpp:14:77: error: expected constructor, destructor, or type conversion before ‘(’ token
 rcmp::hook_function<0x0809472A, int(gplayer_imp*, int, const void*, size_t)>([](auto original, gplayer_imp* self, int cmd_type, const void* buf, size_t size) {
                                                                             ^
/root/lib-173/hook.cpp:23:2: error: expected unqualified-id before ‘)’ token
 });

我正在使用项目:https://github.com/Smertig/rcmp 挂钩函数,但是在编译时收到错误

我的钩子.cpp文件:

#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"

#include <rcmp.hpp>

#include <array>
 

struct gplayer_imp; 




rcmp::hook_function<0x0809472A, int(gplayer_imp*, int, const void*, size_t)>([](auto original, gplayer_imp* self, int cmd_type, const void* buf, size_t size) {
  
  if (cmd_type == 174 && size < 6) {
    
    return 0;
  }

 
  return original(self, cmd_type, buf, size);
});

我的CMakeLists.txt :

cmake_minimum_required(VERSION 3.16)
project(hook)


set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(SOURCE_FILES hook.cpp)


add_library(hook SHARED ${SOURCE_FILES})


target_compile_options(hook PRIVATE -std=c++17)


add_subdirectory(/root/lib-173/rcmp)


include_directories(/root/lib-173/rcmp/include)


target_link_libraries(hook PRIVATE rcmp)

不幸的是,所有更改都是失败的,因为根据代码,加拿大皇家骑警不接受新标准。 我尝试添加其他标头或修改CMakeLists.txt,但没有成功。

应该怎么做才能解决?

如果我已经有了答案,我还没有找到。

非常感谢您的帮助

Linux 编译器错误 C++17 子预期条件

评论


答: 暂无答案