Git Product home page Git Product logo

Comments (10)

ZsGyao avatar ZsGyao commented on June 25, 2024

我在CmakeList中使用_D_const_ = __unused__解决了一部分问题,但是在rpc/rpc_session仍然出现了这个bug

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

用的编译器是g++11.3

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

您好,对于这个问题,brpc compile failed with error "error: macro "__has_attribute" requires an identifier" #1693 也有相同的问题出现,我使用相同的方法更改,但并未完全解决问题,所以我使用了另一种方法供参考,但这种方法是不推荐的。
这个问题的出现是由于gcc对于const解释不彻底导致的。
sudo vim /usr/include/x86_64-linux-gnu/sys/cdefs.h
进行如下更改

/* This declaration tells the compiler that the value is constant. */
// #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (const)
#if __GNUC_PREREQ (2,5)
define attribute_const attribute ((const))
#else
define attribute_const /* Ignore */
#endif

编译通过

[ 96%] Building CXX object CMakeFiles/acid_static.dir/acid/rpc/rpc_session.cpp.o
[100%] Linking CXX static library ../lib/libacid.a
[100%] Built target acid_static

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

同时libgo也存在相同的问题,我已经在libgo提交了issue。

from acid.

zavier-wong avatar zavier-wong commented on June 25, 2024

您好,具体是在rpc/rpc_session的哪个部分代码编译有问题

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

感谢您及时的回复
在CmakeList中CXX_FLAGS中将参数-D__const__= 改为 -D__const__=__unused__可以解决下面这个报错

[  3%] Building CXX object CMakeFiles/acid_static.dir/acid/common/byte_array.cpp.o
In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586,
                 from /usr/include/c++/11/iosfwd:38,
                 from /usr/include/c++/11/ios:38,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/fstream:38,
                 from /home/xxx/Downloads/acid/acid/common/byte_array.cpp:5:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:314:60: error: macro "__has_attribute" requires an identifier
  314 | #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
      |                                                            ^
make[2]: *** [CMakeFiles/acid_static.dir/build.make:76:CMakeFiles/acid_static.dir/acid/common/byte_array.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/acid_static.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2

这是参考brpc的方案解决的,但是在后续编译时仍然遇到了下面这个报错,在试过修改系统的方式(上面提到的)后可以通过编译,我认为可能不是代码的问题。ps. libgo在修改-D__const__=__unused__后已经通过make && make install,我不清楚这由于是不是libgo的引起的
具体报错如下

[ 93%] Building CXX object CMakeFiles/acid_static.dir/acid/rpc/rpc_server.cpp.o
[ 96%] Building CXX object CMakeFiles/acid_static.dir/acid/rpc/rpc_session.cpp.o
In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586,
                 from /usr/include/c++/11/type_traits:38,
                 from /usr/include/c++/11/unordered_map:38,
                 from /usr/local/include/libgo/common/config.h:3,
                 from /usr/local/include/libgo/coroutine.h:3,
                 from /usr/local/include/libgo/libgo.h:2,
                 from /home/xxx/Downloads/acid/acid/rpc/rpc_session.h:8,
                 from /home/xxx/Downloads/acid/acid/rpc/rpc_session.cpp:5:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:314:60: error: macro "__has_attribute" requires an identifier
  314 | #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
      |                                                            ^
make[2]: *** [CMakeFiles/acid_static.dir/build.make:454:CMakeFiles/acid_static.dir/acid/rpc/rpc_session.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/acid_static.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2

from acid.

zavier-wong avatar zavier-wong commented on June 25, 2024

晕,这bug完全没有头绪啊😂

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

hhh,我也觉得,之前弄了一天,最后只能改系统那个文件啦,编译完改回来就可以了。
不过感觉在g++11没解决这个问题前,cmake的cxx_flag里加上-D__const__=__unused__是推荐的,可以看一下我提交的pr

from acid.

zavier-wong avatar zavier-wong commented on June 25, 2024

我好像找到了,之前模仿libgo写cmake,把这条一起写进CMakeList了
set(CMAKE_CXX_FLAGS "-std=c++20 -D__const__= -fPIC -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
但是我并不需要-D__const__= 这条flag
所以这行应该改为set(CMAKE_CXX_FLAGS "-std=c++20 -fPIC -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")

from acid.

ZsGyao avatar ZsGyao commented on June 25, 2024

尝试了一下,还是出现了这种问题🧐,暂时没什么其他解决办法了

from acid.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.