Skip to content

Commit

Permalink
use c++14 mode for compilation (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored and qinzuoyan committed May 28, 2019
1 parent 7e6af96 commit 89eb360
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ cache:

addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
packages:
- clang-format-3.9
- g++-5

before_install:
- wget https://raw.githubusercontent.com/xiaomi/pegasus-common/master/build-depends.tar.gz
Expand All @@ -25,9 +29,6 @@ before_install:
- ls | xargs sudo dpkg -i --force-depends
- cd ..

install:
# - ./run.sh format

before_script:
- cd thirdparty
- wget https://raw.githubusercontent.com/xiaomi/pegasus-common/master/pegasus-thirdparty-prebuild.tar.gz
Expand All @@ -37,7 +38,7 @@ before_script:
- ulimit -c unlimited -S

script:
- ./run.sh test --skip_thirdparty --check --disable_gperf
- ./run.sh test --compiler "gcc-5,g++-5" --skip_thirdparty --check --disable_gperf

after_script:
- ./run.sh stop_zk
Expand Down
18 changes: 10 additions & 8 deletions bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,18 @@ function(dsn_setup_compiler_flags)
# We want access to the PRI* print format macros.
add_definitions(-D__STDC_FORMAT_MACROS)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" CACHE STRING "" FORCE)
else()
message(FATAL_ERROR "You need a compiler with C++14 support.")
endif()

# -fno-omit-frame-pointer
# use frame pointers to allow simple stack frame walking for backtraces.
# This has a small perf hit but worth it for the ability to profile in production
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -fno-omit-frame-pointer" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer" CACHE STRING "" FORCE)

# -Wall: Enable all warnings.
add_compile_options(-Wall)
Expand Down Expand Up @@ -336,14 +344,8 @@ function(dsn_common_setup)

set(BUILD_SHARED_LIBS OFF)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
if(NOT ${COMPILER_SUPPORTS_CXX1Y})
message(FATAL_ERROR "You need a compiler with C++1y support.")
endif()

dsn_setup_system_libs()
dsn_setup_compiler_flags()
dsn_setup_include_path()
dsn_setup_link_path()
endfunction(dsn_common_setup)
endfunction(dsn_common_setup)
10 changes: 5 additions & 5 deletions src/core/core/fail_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "fail_point_impl.h"

#include <dsn/c/api_layer1.h>
#include <boost/regex.hpp>
#include <regex>
#include <dsn/utility/rand.h>

namespace dsn {
Expand Down Expand Up @@ -57,13 +57,13 @@ bool fail_point::parse_from_string(string_view action)
_max_cnt = -1;
_freq = 100;

boost::regex regex(R"((\d+\%)?(\d+\*)?(\w+)(\((.*)\))?)");
boost::smatch match;
std::regex regex(R"((\d+\%)?(\d+\*)?(\w+)(\((.*)\))?)");
std::smatch match;

std::string tmp(action.data(), action.length());
if (boost::regex_match(tmp, match, regex)) {
if (std::regex_match(tmp, match, regex)) {
if (match.size() == 6) {
boost::ssub_match sub_match = match[1];
std::ssub_match sub_match = match[1];
if (!sub_match.str().empty()) {
sscanf(sub_match.str().data(), "%d%%", &_freq);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(MY_PROJ_INC_PATH
../core ../tools/common ../tools/simulator ../tools/hpc ../tools/nfs
)

set(MY_BOOST_PACKAGES system filesystem regex)
set(MY_BOOST_PACKAGES system filesystem)

set(MY_PROJ_LIBS gtest
dsn_runtime
Expand Down

0 comments on commit 89eb360

Please sign in to comment.