Clang 11.0 编译的问题
- Dominant language
- C++
- Stars
- 17.6k
- Forks
- 4.1k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 69
Description
1. src/bvar/scoped_timer.h
第50行
`void reset() { _start_time = butil::cpuwide_time_us(); }
`
错误,_start_time为const
`const int64_t _start_time;
`
2. brpc的CMakeLists.txt里,当cmake 版本大于3.1.3的时候(第125行),用了
```
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
```
这就造成我在cmake版本大于3.1.3的时候,无法修改生成的选项(例如自动生成-std=gnu++11,而我需要-std=c++11 -stdlib=libc++,选项不同在link其他库的时候,例如protobuf库如果是用-stdlib=libc++生成的话,brpc不加-stdlib=libc++会造成link error。
这里貌似没有什么必要区分cmake版本,
```
if(CMAKE_VERSION VERSION_LESS "3.1.3")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
```
直接修改成
`set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
`
应该没什么问题
Contributor guide
Research direction
Check src/bvar/scoped_timer.h around line 50 and brpc's CMakeLists.txt around line 125. Reproduce the Clang 11 build errors and inspect the existing CMake version handling. Done means the const-related compilation issue is resolved and users can select -std=c++11 and -stdlib=libc++ without incompatible generated flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100