Comments (10)
我在CmakeList中使用_D_const_ = __unused__解决了一部分问题,但是在rpc/rpc_session仍然出现了这个bug
from acid.
用的编译器是g++11.3
from acid.
您好,对于这个问题,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.
同时libgo也存在相同的问题,我已经在libgo提交了issue。
from acid.
您好,具体是在rpc/rpc_session的哪个部分代码编译有问题
from acid.
感谢您及时的回复
在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.
晕,这bug完全没有头绪啊😂
from acid.
hhh,我也觉得,之前弄了一天,最后只能改系统那个文件啦,编译完改回来就可以了。
不过感觉在g++11没解决这个问题前,cmake的cxx_flag里加上-D__const__=__unused__是推荐的,可以看一下我提交的pr
from acid.
我好像找到了,之前模仿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.
尝试了一下,还是出现了这种问题🧐,暂时没什么其他解决办法了
from acid.
Related Issues (14)
- 关于c++20编译的问题 HOT 6
- 运行测试文件 test_scheduler.cpp 时出现问题 HOT 1
- 关于LogManager中m_loggers类型的问题 HOT 1
- 同学docs里面的两张图片是都挂了吗 HOT 1
- 编译到 Linking CXX executable ../../bin/test/test_log 出现问题 HOT 6
- 负载均衡 HOT 1
- 关于协程的实现 HOT 2
- rpc 是否支持http2.0 HOT 3
- test_fiber测试出现stack smashing detected *** HOT 3
- 日志冲突,第三个集群开启失败 HOT 2
- 大佬您好,我想请教一下我在tests/kvraft编译的时候遇到缺少raft库的情况 HOT 5
- 关于负载均衡模块的疑惑 HOT 5
- 请问如果想在example中新增其他的provider和consumer改如何处理呢 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acid.