This is an automated email from the ASF dual-hosted git repository.

guangmingchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 0608aa1e Fix gflag namespace of example and tools (#2879)
0608aa1e is described below

commit 0608aa1e13d59e6af233efa0e2be95bbee4912d1
Author: Bright Chen <chenguangmin...@foxmail.com>
AuthorDate: Sun Jan 19 21:28:55 2025 +0800

    Fix gflag namespace of example and tools (#2879)
---
 CMakeLists.txt                                       | 13 +------------
 example/BUILD.bazel                                  |  1 -
 example/asynchronous_echo_c++/CMakeLists.txt         | 13 +------------
 example/asynchronous_echo_c++/client.cpp             |  2 +-
 example/asynchronous_echo_c++/server.cpp             |  2 +-
 example/auto_concurrency_limiter/CMakeLists.txt      | 13 +------------
 example/auto_concurrency_limiter/client.cpp          |  2 +-
 example/auto_concurrency_limiter/server.cpp          |  2 +-
 example/backup_request_c++/CMakeLists.txt            | 13 +------------
 example/backup_request_c++/client.cpp                |  2 +-
 example/backup_request_c++/server.cpp                |  2 +-
 example/baidu_proxy_and_generic_call/CMakeLists.txt  | 13 +------------
 example/baidu_proxy_and_generic_call/client.cpp      |  2 +-
 example/baidu_proxy_and_generic_call/proxy.cpp       |  2 +-
 example/baidu_proxy_and_generic_call/server.cpp      |  2 +-
 example/bthread_tag_echo_c++/CMakeLists.txt          | 13 +------------
 example/bthread_tag_echo_c++/client.cpp              |  2 +-
 example/bthread_tag_echo_c++/server.cpp              |  4 ++--
 example/cancel_c++/CMakeLists.txt                    | 13 +------------
 example/cancel_c++/client.cpp                        |  2 +-
 example/cancel_c++/server.cpp                        |  2 +-
 example/cascade_echo_c++/CMakeLists.txt              | 13 +------------
 example/cascade_echo_c++/client.cpp                  |  4 ++--
 example/cascade_echo_c++/server.cpp                  |  4 ++--
 example/coroutine/coroutine_server.cpp               |  4 ++--
 example/dynamic_partition_echo_c++/CMakeLists.txt    | 13 +------------
 example/dynamic_partition_echo_c++/client.cpp        |  2 +-
 example/dynamic_partition_echo_c++/server.cpp        |  2 +-
 example/echo_c++/CMakeLists.txt                      | 13 +------------
 example/echo_c++/client.cpp                          |  2 +-
 example/echo_c++/server.cpp                          |  2 +-
 example/grpc_c++/CMakeLists.txt                      | 14 +-------------
 example/grpc_c++/client.cpp                          |  4 ++--
 example/grpc_c++/server.cpp                          |  2 +-
 example/http_c++/CMakeLists.txt                      | 14 +-------------
 example/http_c++/benchmark_http.cpp                  |  2 +-
 example/http_c++/http_client.cpp                     |  2 +-
 example/http_c++/http_server.cpp                     |  2 +-
 example/memcache_c++/CMakeLists.txt                  | 13 +------------
 example/memcache_c++/client.cpp                      |  2 +-
 example/multi_threaded_echo_c++/CMakeLists.txt       | 13 +------------
 example/multi_threaded_echo_c++/client.cpp           |  2 +-
 example/multi_threaded_echo_c++/server.cpp           |  4 ++--
 example/multi_threaded_echo_fns_c++/CMakeLists.txt   | 13 +------------
 example/multi_threaded_echo_fns_c++/client.cpp       |  2 +-
 example/multi_threaded_echo_fns_c++/server.cpp       |  2 +-
 example/nshead_extension_c++/CMakeLists.txt          | 13 +------------
 example/nshead_extension_c++/client.cpp              |  2 +-
 example/nshead_extension_c++/server.cpp              |  2 +-
 example/nshead_pb_extension_c++/CMakeLists.txt       | 13 +------------
 example/nshead_pb_extension_c++/client.cpp           |  2 +-
 example/nshead_pb_extension_c++/server.cpp           |  2 +-
 example/parallel_echo_c++/CMakeLists.txt             | 13 +------------
 example/parallel_echo_c++/client.cpp                 |  2 +-
 example/parallel_echo_c++/server.cpp                 |  2 +-
 example/partition_echo_c++/CMakeLists.txt            | 13 +------------
 example/partition_echo_c++/client.cpp                |  2 +-
 example/partition_echo_c++/server.cpp                |  2 +-
 example/rdma_performance/CMakeLists.txt              | 12 +-----------
 example/rdma_performance/client.cpp                  |  2 +-
 example/rdma_performance/server.cpp                  |  2 +-
 example/redis_c++/CMakeLists.txt                     | 13 +------------
 example/redis_c++/redis_cli.cpp                      |  2 +-
 example/redis_c++/redis_press.cpp                    |  2 +-
 example/rpcz_echo_c++/CMakeLists.txt                 | 13 +------------
 example/rpcz_echo_c++/client.cpp                     |  2 +-
 example/rpcz_echo_c++/server.cpp                     |  2 +-
 example/selective_echo_c++/CMakeLists.txt            | 13 +------------
 example/selective_echo_c++/client.cpp                |  2 +-
 example/selective_echo_c++/server.cpp                |  2 +-
 example/session_data_and_thread_local/CMakeLists.txt | 13 +------------
 example/session_data_and_thread_local/client.cpp     |  2 +-
 example/session_data_and_thread_local/server.cpp     |  2 +-
 example/streaming_batch_echo_c++/CMakeLists.txt      | 13 +------------
 example/streaming_batch_echo_c++/client.cpp          |  2 +-
 example/streaming_batch_echo_c++/server.cpp          |  2 +-
 example/streaming_echo_c++/CMakeLists.txt            | 13 +------------
 example/streaming_echo_c++/client.cpp                |  2 +-
 example/streaming_echo_c++/server.cpp                |  2 +-
 example/thrift_extension_c++/client2.cpp             |  2 +-
 tools/BUILD                                          |  1 -
 tools/parallel_http/parallel_http.cpp                |  2 +-
 tools/rpc_press/rpc_press.cpp                        |  2 +-
 tools/rpc_replay/rpc_replay.cpp                      |  2 +-
 tools/rpc_view/rpc_view.cpp                          | 10 +++++-----
 tools/trackme_server/trackme_server.cpp              |  2 +-
 86 files changed, 94 insertions(+), 383 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 284f27fe..afc2de4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,17 +114,6 @@ list(APPEND CMAKE_MODULE_PATH 
"${PROJECT_SOURCE_DIR}/cmake")
 
 find_package(GFLAGS REQUIRED)
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-
 include_directories(
     ${PROJECT_SOURCE_DIR}/src
     ${CMAKE_CURRENT_BINARY_DIR}
@@ -144,7 +133,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wno-deprecated-declarations 
-Wno-inconsistent-missing-override")
 endif()
 
-set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} 
-DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} 
-DGFLAGS_NS=${GFLAGS_NS} 
-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=${WITH_DEBUG_BTHREAD_SCHE_SAFETY_VAL} 
-DBRPC_DEBUG_LOCK=${WITH_DEBUG_LOCK_VAL}")
+set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} 
-DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} 
-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=${WITH_DEBUG_BTHREAD_SCHE_SAFETY_VAL} 
-DBRPC_DEBUG_LOCK=${WITH_DEBUG_LOCK_VAL}")
 if(WITH_MESALINK)
     set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DUSE_MESALINK")
 endif()
diff --git a/example/BUILD.bazel b/example/BUILD.bazel
index afc525a3..b38cd5a1 100644
--- a/example/BUILD.bazel
+++ b/example/BUILD.bazel
@@ -28,7 +28,6 @@ COPTS = [
     "-fPIC",
     "-Wno-unused-parameter",
     "-fno-omit-frame-pointer",
-    "-DGFLAGS_NS=google",
 ] + select({
     "//bazel/config:brpc_with_glog": ["-DBRPC_WITH_GLOG=1"],
     "//conditions:default": ["-DBRPC_WITH_GLOG=0"],
diff --git a/example/asynchronous_echo_c++/CMakeLists.txt 
b/example/asynchronous_echo_c++/CMakeLists.txt
index 2946e299..37cb5f38 100644
--- a/example/asynchronous_echo_c++/CMakeLists.txt
+++ b/example/asynchronous_echo_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/asynchronous_echo_c++/client.cpp 
b/example/asynchronous_echo_c++/client.cpp
index e77918cb..b52297b4 100644
--- a/example/asynchronous_echo_c++/client.cpp
+++ b/example/asynchronous_echo_c++/client.cpp
@@ -51,7 +51,7 @@ void HandleEchoResponse(
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/asynchronous_echo_c++/server.cpp 
b/example/asynchronous_echo_c++/server.cpp
index 7aad241f..dcce19a8 100644
--- a/example/asynchronous_echo_c++/server.cpp
+++ b/example/asynchronous_echo_c++/server.cpp
@@ -87,7 +87,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/auto_concurrency_limiter/CMakeLists.txt 
b/example/auto_concurrency_limiter/CMakeLists.txt
index 4d4802c8..a496dd57 100644
--- a/example/auto_concurrency_limiter/CMakeLists.txt
+++ b/example/auto_concurrency_limiter/CMakeLists.txt
@@ -51,16 +51,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -69,8 +59,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/auto_concurrency_limiter/client.cpp 
b/example/auto_concurrency_limiter/client.cpp
index 13377f04..d33325dd 100644
--- a/example/auto_concurrency_limiter/client.cpp
+++ b/example/auto_concurrency_limiter/client.cpp
@@ -215,7 +215,7 @@ void RunCase(test::ControlService_Stub &cntl_stub,
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     Expose();
 
     brpc::Channel channel;
diff --git a/example/auto_concurrency_limiter/server.cpp 
b/example/auto_concurrency_limiter/server.cpp
index 5d731454..61f826fa 100644
--- a/example/auto_concurrency_limiter/server.cpp
+++ b/example/auto_concurrency_limiter/server.cpp
@@ -271,7 +271,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     bthread::FLAGS_bthread_concurrency= FLAGS_server_bthread_concurrency;
 
     brpc::Server server;
diff --git a/example/backup_request_c++/CMakeLists.txt 
b/example/backup_request_c++/CMakeLists.txt
index 5b91114b..3c8d34a0 100644
--- a/example/backup_request_c++/CMakeLists.txt
+++ b/example/backup_request_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/backup_request_c++/client.cpp 
b/example/backup_request_c++/client.cpp
index dfbb5856..07005e37 100644
--- a/example/backup_request_c++/client.cpp
+++ b/example/backup_request_c++/client.cpp
@@ -35,7 +35,7 @@ DEFINE_int32(backup_request_ms, 2, "Timeout for sending 
backup request");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/backup_request_c++/server.cpp 
b/example/backup_request_c++/server.cpp
index 198120f1..9bc8a578 100644
--- a/example/backup_request_c++/server.cpp
+++ b/example/backup_request_c++/server.cpp
@@ -78,7 +78,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/baidu_proxy_and_generic_call/CMakeLists.txt 
b/example/baidu_proxy_and_generic_call/CMakeLists.txt
index 88c691df..7e34d0a8 100644
--- a/example/baidu_proxy_and_generic_call/CMakeLists.txt
+++ b/example/baidu_proxy_and_generic_call/CMakeLists.txt
@@ -51,16 +51,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -69,8 +59,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/baidu_proxy_and_generic_call/client.cpp 
b/example/baidu_proxy_and_generic_call/client.cpp
index d8040740..b8fd3101 100644
--- a/example/baidu_proxy_and_generic_call/client.cpp
+++ b/example/baidu_proxy_and_generic_call/client.cpp
@@ -34,7 +34,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between 
consecutive requests");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/baidu_proxy_and_generic_call/proxy.cpp 
b/example/baidu_proxy_and_generic_call/proxy.cpp
index 81e1176b..a7f24fbc 100644
--- a/example/baidu_proxy_and_generic_call/proxy.cpp
+++ b/example/baidu_proxy_and_generic_call/proxy.cpp
@@ -111,7 +111,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/baidu_proxy_and_generic_call/server.cpp 
b/example/baidu_proxy_and_generic_call/server.cpp
index b3f16173..64d49366 100644
--- a/example/baidu_proxy_and_generic_call/server.cpp
+++ b/example/baidu_proxy_and_generic_call/server.cpp
@@ -78,7 +78,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/bthread_tag_echo_c++/CMakeLists.txt 
b/example/bthread_tag_echo_c++/CMakeLists.txt
index 3dd7a245..d91aa6ca 100644
--- a/example/bthread_tag_echo_c++/CMakeLists.txt
+++ b/example/bthread_tag_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/bthread_tag_echo_c++/client.cpp 
b/example/bthread_tag_echo_c++/client.cpp
index 2af1a8a6..2b5a9e0b 100644
--- a/example/bthread_tag_echo_c++/client.cpp
+++ b/example/bthread_tag_echo_c++/client.cpp
@@ -84,7 +84,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/bthread_tag_echo_c++/server.cpp 
b/example/bthread_tag_echo_c++/server.cpp
index ed4ba4d6..0d14bd1d 100644
--- a/example/bthread_tag_echo_c++/server.cpp
+++ b/example/bthread_tag_echo_c++/server.cpp
@@ -74,10 +74,10 @@ static void* my_background_task(void*) {
 
 int main(int argc, char* argv[]) {
     std::string help_str = "dummy help infomation";
-    GFLAGS_NS::SetUsageMessage(help_str);
+    GFLAGS_NAMESPACE::SetUsageMessage(help_str);
 
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_h) {
         fprintf(stderr, "%s\n%s\n%s", help_str.c_str(), help_str.c_str(), 
help_str.c_str());
diff --git a/example/cancel_c++/CMakeLists.txt 
b/example/cancel_c++/CMakeLists.txt
index d6246c67..b8d64dda 100644
--- a/example/cancel_c++/CMakeLists.txt
+++ b/example/cancel_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/cancel_c++/client.cpp b/example/cancel_c++/client.cpp
index b1ba1aeb..dd23b679 100644
--- a/example/cancel_c++/client.cpp
+++ b/example/cancel_c++/client.cpp
@@ -45,7 +45,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/cancel_c++/server.cpp b/example/cancel_c++/server.cpp
index 5fa5e17a..b85ec09a 100644
--- a/example/cancel_c++/server.cpp
+++ b/example/cancel_c++/server.cpp
@@ -73,7 +73,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/cascade_echo_c++/CMakeLists.txt 
b/example/cascade_echo_c++/CMakeLists.txt
index bfb11025..453067b1 100644
--- a/example/cascade_echo_c++/CMakeLists.txt
+++ b/example/cascade_echo_c++/CMakeLists.txt
@@ -57,16 +57,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -75,8 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/cascade_echo_c++/client.cpp 
b/example/cascade_echo_c++/client.cpp
index cb545b6e..25a1b52f 100644
--- a/example/cascade_echo_c++/client.cpp
+++ b/example/cascade_echo_c++/client.cpp
@@ -87,8 +87,8 @@ void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::SetUsageMessage("Send EchoRequest to server every second");
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::SetUsageMessage("Send EchoRequest to server every 
second");
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/cascade_echo_c++/server.cpp 
b/example/cascade_echo_c++/server.cpp
index de19e660..c329073c 100644
--- a/example/cascade_echo_c++/server.cpp
+++ b/example/cascade_echo_c++/server.cpp
@@ -85,8 +85,8 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::SetUsageMessage("A server that may call itself");
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::SetUsageMessage("A server that may call itself");
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/coroutine/coroutine_server.cpp 
b/example/coroutine/coroutine_server.cpp
index 9df50b04..51ef7fcb 100644
--- a/example/coroutine/coroutine_server.cpp
+++ b/example/coroutine/coroutine_server.cpp
@@ -111,9 +111,9 @@ int main(int argc, char* argv[]) {
     bthread_setconcurrency(BTHREAD_MIN_CONCURRENCY);
 
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     if (FLAGS_enable_coroutine) {
-        GFLAGS_NS::SetCommandLineOption("usercode_in_coroutine", "true");
+        GFLAGS_NAMESPACE::SetCommandLineOption("usercode_in_coroutine", 
"true");
     }
 
     // Generally you only need one Server.
diff --git a/example/dynamic_partition_echo_c++/CMakeLists.txt 
b/example/dynamic_partition_echo_c++/CMakeLists.txt
index a5724d2c..cf79c8cb 100644
--- a/example/dynamic_partition_echo_c++/CMakeLists.txt
+++ b/example/dynamic_partition_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/dynamic_partition_echo_c++/client.cpp 
b/example/dynamic_partition_echo_c++/client.cpp
index 6c83b086..fd25514c 100644
--- a/example/dynamic_partition_echo_c++/client.cpp
+++ b/example/dynamic_partition_echo_c++/client.cpp
@@ -122,7 +122,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/dynamic_partition_echo_c++/server.cpp 
b/example/dynamic_partition_echo_c++/server.cpp
index 0047e01c..e86affaa 100644
--- a/example/dynamic_partition_echo_c++/server.cpp
+++ b/example/dynamic_partition_echo_c++/server.cpp
@@ -94,7 +94,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_server_num <= 0) {
         LOG(ERROR) << "server_num must be positive";
diff --git a/example/echo_c++/CMakeLists.txt b/example/echo_c++/CMakeLists.txt
index 54fdd570..02d24779 100644
--- a/example/echo_c++/CMakeLists.txt
+++ b/example/echo_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/echo_c++/client.cpp b/example/echo_c++/client.cpp
index 337aa6e9..3cc83f72 100644
--- a/example/echo_c++/client.cpp
+++ b/example/echo_c++/client.cpp
@@ -34,7 +34,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between 
consecutive requests");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/echo_c++/server.cpp b/example/echo_c++/server.cpp
index d1f06051..cc0050ae 100644
--- a/example/echo_c++/server.cpp
+++ b/example/echo_c++/server.cpp
@@ -94,7 +94,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/grpc_c++/CMakeLists.txt b/example/grpc_c++/CMakeLists.txt
index 6250d2ab..3d947688 100644
--- a/example/grpc_c++/CMakeLists.txt
+++ b/example/grpc_c++/CMakeLists.txt
@@ -55,17 +55,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -74,8 +63,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/grpc_c++/client.cpp b/example/grpc_c++/client.cpp
index 0ce4b90b..4318ed88 100644
--- a/example/grpc_c++/client.cpp
+++ b/example/grpc_c++/client.cpp
@@ -33,9 +33,9 @@ DEFINE_bool(gzip, false, "compress body using gzip");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     if (FLAGS_gzip) {
-        GFLAGS_NS::SetCommandLineOption("http_body_compress_threshold", 0);
+        GFLAGS_NAMESPACE::SetCommandLineOption("http_body_compress_threshold", 
0);
     }
     
     // A Channel represents a communication line to a Server. Notice that 
diff --git a/example/grpc_c++/server.cpp b/example/grpc_c++/server.cpp
index 50e21dba..7658556e 100644
--- a/example/grpc_c++/server.cpp
+++ b/example/grpc_c++/server.cpp
@@ -47,7 +47,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/http_c++/CMakeLists.txt b/example/http_c++/CMakeLists.txt
index c5e7d40a..66c4deec 100644
--- a/example/http_c++/CMakeLists.txt
+++ b/example/http_c++/CMakeLists.txt
@@ -62,17 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
-
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -81,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/http_c++/benchmark_http.cpp 
b/example/http_c++/benchmark_http.cpp
index 3ddcfe14..7fc879d1 100644
--- a/example/http_c++/benchmark_http.cpp
+++ b/example/http_c++/benchmark_http.cpp
@@ -74,7 +74,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/http_c++/http_client.cpp b/example/http_c++/http_client.cpp
index d9984c88..23222dee 100644
--- a/example/http_c++/http_client.cpp
+++ b/example/http_c++/http_client.cpp
@@ -38,7 +38,7 @@ DECLARE_bool(http_verbose);
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (argc != 2) {
         LOG(ERROR) << "Usage: ./http_client \"http(s)://www.foo.com\"";
diff --git a/example/http_c++/http_server.cpp b/example/http_c++/http_server.cpp
index 3a806c43..05c9a0ee 100644
--- a/example/http_c++/http_server.cpp
+++ b/example/http_c++/http_server.cpp
@@ -225,7 +225,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/memcache_c++/CMakeLists.txt 
b/example/memcache_c++/CMakeLists.txt
index 7236f01c..e3e70f96 100644
--- a/example/memcache_c++/CMakeLists.txt
+++ b/example/memcache_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/memcache_c++/client.cpp b/example/memcache_c++/client.cpp
index 01b03651..5f321988 100644
--- a/example/memcache_c++/client.cpp
+++ b/example/memcache_c++/client.cpp
@@ -101,7 +101,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     if (FLAGS_exptime < 0) {
         FLAGS_exptime = 0;
     }
diff --git a/example/multi_threaded_echo_c++/CMakeLists.txt 
b/example/multi_threaded_echo_c++/CMakeLists.txt
index 896483af..d57886b6 100644
--- a/example/multi_threaded_echo_c++/CMakeLists.txt
+++ b/example/multi_threaded_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/multi_threaded_echo_c++/client.cpp 
b/example/multi_threaded_echo_c++/client.cpp
index 0b7ea28c..fa9768c7 100644
--- a/example/multi_threaded_echo_c++/client.cpp
+++ b/example/multi_threaded_echo_c++/client.cpp
@@ -85,7 +85,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/multi_threaded_echo_c++/server.cpp 
b/example/multi_threaded_echo_c++/server.cpp
index b747487f..54ca0960 100644
--- a/example/multi_threaded_echo_c++/server.cpp
+++ b/example/multi_threaded_echo_c++/server.cpp
@@ -56,10 +56,10 @@ DEFINE_bool(h, false, "print help information");
 
 int main(int argc, char* argv[]) {
     std::string help_str = "dummy help infomation";
-    GFLAGS_NS::SetUsageMessage(help_str);
+    GFLAGS_NAMESPACE::SetUsageMessage(help_str);
 
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_h) {
         fprintf(stderr, "%s\n%s\n%s", help_str.c_str(), help_str.c_str(), 
help_str.c_str());
diff --git a/example/multi_threaded_echo_fns_c++/CMakeLists.txt 
b/example/multi_threaded_echo_fns_c++/CMakeLists.txt
index c934f7aa..0805485d 100644
--- a/example/multi_threaded_echo_fns_c++/CMakeLists.txt
+++ b/example/multi_threaded_echo_fns_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/multi_threaded_echo_fns_c++/client.cpp 
b/example/multi_threaded_echo_fns_c++/client.cpp
index cec7f0d4..895b3e55 100644
--- a/example/multi_threaded_echo_fns_c++/client.cpp
+++ b/example/multi_threaded_echo_fns_c++/client.cpp
@@ -91,7 +91,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/multi_threaded_echo_fns_c++/server.cpp 
b/example/multi_threaded_echo_fns_c++/server.cpp
index c9576e68..2e837bbf 100644
--- a/example/multi_threaded_echo_fns_c++/server.cpp
+++ b/example/multi_threaded_echo_fns_c++/server.cpp
@@ -97,7 +97,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_server_num <= 0) {
         LOG(ERROR) << "server_num must be positive";
diff --git a/example/nshead_extension_c++/CMakeLists.txt 
b/example/nshead_extension_c++/CMakeLists.txt
index 5aa496ac..244bca68 100644
--- a/example/nshead_extension_c++/CMakeLists.txt
+++ b/example/nshead_extension_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/nshead_extension_c++/client.cpp 
b/example/nshead_extension_c++/client.cpp
index b5263d52..bfc48b6f 100644
--- a/example/nshead_extension_c++/client.cpp
+++ b/example/nshead_extension_c++/client.cpp
@@ -35,7 +35,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the 
first RPC)");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/nshead_extension_c++/server.cpp 
b/example/nshead_extension_c++/server.cpp
index b59c2c04..1cbd5728 100644
--- a/example/nshead_extension_c++/server.cpp
+++ b/example/nshead_extension_c++/server.cpp
@@ -51,7 +51,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     brpc::Server server;
     brpc::ServerOptions options;
diff --git a/example/nshead_pb_extension_c++/CMakeLists.txt 
b/example/nshead_pb_extension_c++/CMakeLists.txt
index 0516a9eb..b6302949 100644
--- a/example/nshead_pb_extension_c++/CMakeLists.txt
+++ b/example/nshead_pb_extension_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/nshead_pb_extension_c++/client.cpp 
b/example/nshead_pb_extension_c++/client.cpp
index b5263d52..bfc48b6f 100644
--- a/example/nshead_pb_extension_c++/client.cpp
+++ b/example/nshead_pb_extension_c++/client.cpp
@@ -35,7 +35,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the 
first RPC)");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/nshead_pb_extension_c++/server.cpp 
b/example/nshead_pb_extension_c++/server.cpp
index 4f67ecd8..d87c9a27 100644
--- a/example/nshead_pb_extension_c++/server.cpp
+++ b/example/nshead_pb_extension_c++/server.cpp
@@ -97,7 +97,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     brpc::Server server;
     example::EchoServiceImpl echo_service_impl;
diff --git a/example/parallel_echo_c++/CMakeLists.txt 
b/example/parallel_echo_c++/CMakeLists.txt
index b70d7571..7cdb412a 100644
--- a/example/parallel_echo_c++/CMakeLists.txt
+++ b/example/parallel_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/parallel_echo_c++/client.cpp 
b/example/parallel_echo_c++/client.cpp
index 933e2b65..54ce661d 100644
--- a/example/parallel_echo_c++/client.cpp
+++ b/example/parallel_echo_c++/client.cpp
@@ -94,7 +94,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/parallel_echo_c++/server.cpp 
b/example/parallel_echo_c++/server.cpp
index 364b29ed..c57e0011 100644
--- a/example/parallel_echo_c++/server.cpp
+++ b/example/parallel_echo_c++/server.cpp
@@ -52,7 +52,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/partition_echo_c++/CMakeLists.txt 
b/example/partition_echo_c++/CMakeLists.txt
index 2e09c388..4d845c72 100644
--- a/example/partition_echo_c++/CMakeLists.txt
+++ b/example/partition_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/partition_echo_c++/client.cpp 
b/example/partition_echo_c++/client.cpp
index 83fa001e..b60a63d0 100644
--- a/example/partition_echo_c++/client.cpp
+++ b/example/partition_echo_c++/client.cpp
@@ -123,7 +123,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/partition_echo_c++/server.cpp 
b/example/partition_echo_c++/server.cpp
index 4c2053f8..aa65d41b 100644
--- a/example/partition_echo_c++/server.cpp
+++ b/example/partition_echo_c++/server.cpp
@@ -94,7 +94,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_server_num <= 0) {
         LOG(ERROR) << "server_num must be positive";
diff --git a/example/rdma_performance/CMakeLists.txt 
b/example/rdma_performance/CMakeLists.txt
index de730720..2812b0b0 100644
--- a/example/rdma_performance/CMakeLists.txt
+++ b/example/rdma_performance/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,7 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS} 
-DBRPC_WITH_RDMA=1")
+set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_RDMA=1")
 set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/rdma_performance/client.cpp 
b/example/rdma_performance/client.cpp
index e6013b55..57d0c06c 100644
--- a/example/rdma_performance/client.cpp
+++ b/example/rdma_performance/client.cpp
@@ -272,7 +272,7 @@ void Test(int thread_num, int attachment_size) {
 }
 
 int main(int argc, char* argv[]) {
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Initialize RDMA environment in advance.
     if (FLAGS_use_rdma) {
diff --git a/example/rdma_performance/server.cpp 
b/example/rdma_performance/server.cpp
index 9920cbb2..d3d00057 100644
--- a/example/rdma_performance/server.cpp
+++ b/example/rdma_performance/server.cpp
@@ -63,7 +63,7 @@ public:
 }
 
 int main(int argc, char* argv[]) {
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     brpc::Server server;
     test::PerfTestServiceImpl perf_test_service_impl;
diff --git a/example/redis_c++/CMakeLists.txt b/example/redis_c++/CMakeLists.txt
index fc4745c8..e29dcbeb 100644
--- a/example/redis_c++/CMakeLists.txt
+++ b/example/redis_c++/CMakeLists.txt
@@ -67,16 +67,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -85,8 +75,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/redis_c++/redis_cli.cpp b/example/redis_c++/redis_cli.cpp
index d4cbf63a..02124aa3 100644
--- a/example/redis_c++/redis_cli.cpp
+++ b/example/redis_c++/redis_cli.cpp
@@ -77,7 +77,7 @@ static int cli_getc(FILE *stream) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/redis_c++/redis_press.cpp 
b/example/redis_c++/redis_press.cpp
index 7c4e5a5c..165b8bf1 100644
--- a/example/redis_c++/redis_press.cpp
+++ b/example/redis_c++/redis_press.cpp
@@ -97,7 +97,7 @@ static void* sender(void* void_args) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/rpcz_echo_c++/CMakeLists.txt 
b/example/rpcz_echo_c++/CMakeLists.txt
index e377acc1..d1f1d924 100644
--- a/example/rpcz_echo_c++/CMakeLists.txt
+++ b/example/rpcz_echo_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/rpcz_echo_c++/client.cpp b/example/rpcz_echo_c++/client.cpp
index ad80de0f..8cb86866 100644
--- a/example/rpcz_echo_c++/client.cpp
+++ b/example/rpcz_echo_c++/client.cpp
@@ -37,7 +37,7 @@ DEFINE_int32(interval_ms, 1000, "Milliseconds between 
consecutive requests");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // brpc::FLAGS_enable_rpcz = true;
     // A Channel represents a communication line to a Server. Notice that 
diff --git a/example/rpcz_echo_c++/server.cpp b/example/rpcz_echo_c++/server.cpp
index 0f5f7f26..8503e995 100644
--- a/example/rpcz_echo_c++/server.cpp
+++ b/example/rpcz_echo_c++/server.cpp
@@ -132,7 +132,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/selective_echo_c++/CMakeLists.txt 
b/example/selective_echo_c++/CMakeLists.txt
index 49311218..809bd22a 100644
--- a/example/selective_echo_c++/CMakeLists.txt
+++ b/example/selective_echo_c++/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/selective_echo_c++/client.cpp 
b/example/selective_echo_c++/client.cpp
index 99f9f0fd..6f0c413a 100644
--- a/example/selective_echo_c++/client.cpp
+++ b/example/selective_echo_c++/client.cpp
@@ -86,7 +86,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/selective_echo_c++/server.cpp 
b/example/selective_echo_c++/server.cpp
index cd075ac7..0705a328 100644
--- a/example/selective_echo_c++/server.cpp
+++ b/example/selective_echo_c++/server.cpp
@@ -93,7 +93,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_server_num <= 0) {
         LOG(ERROR) << "server_num must be positive";
diff --git a/example/session_data_and_thread_local/CMakeLists.txt 
b/example/session_data_and_thread_local/CMakeLists.txt
index ea1c8381..27f60e58 100644
--- a/example/session_data_and_thread_local/CMakeLists.txt
+++ b/example/session_data_and_thread_local/CMakeLists.txt
@@ -62,16 +62,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -80,8 +70,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
diff --git a/example/session_data_and_thread_local/client.cpp 
b/example/session_data_and_thread_local/client.cpp
index f0cc9892..f075e704 100644
--- a/example/session_data_and_thread_local/client.cpp
+++ b/example/session_data_and_thread_local/client.cpp
@@ -85,7 +85,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/session_data_and_thread_local/server.cpp 
b/example/session_data_and_thread_local/server.cpp
index 5d5efc1c..c196c33e 100644
--- a/example/session_data_and_thread_local/server.cpp
+++ b/example/session_data_and_thread_local/server.cpp
@@ -211,7 +211,7 @@ void AsyncJob::run() {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // The factory to create MySessionLocalData. Must be valid when server is 
running.
     MySessionLocalDataFactory session_local_data_factory;
diff --git a/example/streaming_batch_echo_c++/CMakeLists.txt 
b/example/streaming_batch_echo_c++/CMakeLists.txt
index 1d152ef9..c4340672 100644
--- a/example/streaming_batch_echo_c++/CMakeLists.txt
+++ b/example/streaming_batch_echo_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-        COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-            COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-            OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/streaming_batch_echo_c++/client.cpp 
b/example/streaming_batch_echo_c++/client.cpp
index ea58a191..23f2b06d 100644
--- a/example/streaming_batch_echo_c++/client.cpp
+++ b/example/streaming_batch_echo_c++/client.cpp
@@ -55,7 +55,7 @@ public:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/streaming_batch_echo_c++/server.cpp 
b/example/streaming_batch_echo_c++/server.cpp
index 3690344a..88ea8981 100644
--- a/example/streaming_batch_echo_c++/server.cpp
+++ b/example/streaming_batch_echo_c++/server.cpp
@@ -91,7 +91,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/streaming_echo_c++/CMakeLists.txt 
b/example/streaming_echo_c++/CMakeLists.txt
index ebefaf4f..571991e0 100644
--- a/example/streaming_echo_c++/CMakeLists.txt
+++ b/example/streaming_echo_c++/CMakeLists.txt
@@ -58,16 +58,6 @@ if((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIBRARY))
 endif()
 include_directories(${GFLAGS_INCLUDE_PATH})
 
-execute_process(
-    COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | 
tr -d '\n'"
-    OUTPUT_VARIABLE GFLAGS_NS
-)
-if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
-    execute_process(
-        COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" 
${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | 
tr -d '\n'"
-        OUTPUT_VARIABLE GFLAGS_NS
-    )
-endif()
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     include(CheckFunctionExists)
     CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
@@ -76,8 +66,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     endif()
 endif()
 
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DGFLAGS_NS=${GFLAGS_NS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -DNDEBUG -O2 -D__const__=__unused__ 
-pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer")
+set(CMAKE_CXX_FLAGS "${DEFINE_CLOCK_GETTIME} -DNDEBUG -O2 
-D__const__=__unused__ -pipe -W -Wall -Wno-unused-parameter -fPIC 
-fno-omit-frame-pointer")
 
 if(CMAKE_VERSION VERSION_LESS "3.1.3")
     if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/example/streaming_echo_c++/client.cpp 
b/example/streaming_echo_c++/client.cpp
index d5936251..619f579a 100644
--- a/example/streaming_echo_c++/client.cpp
+++ b/example/streaming_echo_c++/client.cpp
@@ -31,7 +31,7 @@ DEFINE_int32(max_retry, 3, "Max retries(not including the 
first RPC)");
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/example/streaming_echo_c++/server.cpp 
b/example/streaming_echo_c++/server.cpp
index 072105c7..808d88d0 100644
--- a/example/streaming_echo_c++/server.cpp
+++ b/example/streaming_echo_c++/server.cpp
@@ -82,7 +82,7 @@ private:
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // Generally you only need one Server.
     brpc::Server server;
diff --git a/example/thrift_extension_c++/client2.cpp 
b/example/thrift_extension_c++/client2.cpp
index 276dbac0..c6caa0a8 100644
--- a/example/thrift_extension_c++/client2.cpp
+++ b/example/thrift_extension_c++/client2.cpp
@@ -79,7 +79,7 @@ static void* sender(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     // A Channel represents a communication line to a Server. Notice that 
     // Channel is thread-safe and can be shared by all threads in your program.
diff --git a/tools/BUILD b/tools/BUILD
index a836cb04..3abad241 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -25,7 +25,6 @@ COPTS = [
     "-fPIC",
     "-Wno-unused-parameter",
     "-fno-omit-frame-pointer",
-    "-DGFLAGS_NS=google",
 ] + select({
     "//bazel/config:brpc_with_glog": ["-DBRPC_WITH_GLOG=1"],
     "//conditions:default": ["-DBRPC_WITH_GLOG=0"],
diff --git a/tools/parallel_http/parallel_http.cpp 
b/tools/parallel_http/parallel_http.cpp
index 6b863e0b..24ae855c 100644
--- a/tools/parallel_http/parallel_http.cpp
+++ b/tools/parallel_http/parallel_http.cpp
@@ -99,7 +99,7 @@ void* access_thread(void* void_args) {
 
 int main(int argc, char** argv) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     // if (FLAGS_path.empty() || FLAGS_path[0] != '/') {
     //     FLAGS_path = "/" + FLAGS_path;
diff --git a/tools/rpc_press/rpc_press.cpp b/tools/rpc_press/rpc_press.cpp
index 997a9fb0..cb69ccfc 100644
--- a/tools/rpc_press/rpc_press.cpp
+++ b/tools/rpc_press/rpc_press.cpp
@@ -97,7 +97,7 @@ bool set_press_options(pbrpcframework::PressOptions* options){
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     // set global log option
 
     if (FLAGS_dummy_port >= 0) {
diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp
index 2065c238..c3cd7c4c 100644
--- a/tools/rpc_replay/rpc_replay.cpp
+++ b/tools/rpc_replay/rpc_replay.cpp
@@ -217,7 +217,7 @@ static void* replay_thread(void* arg) {
 
 int main(int argc, char* argv[]) {
     // Parse gflags. We recommend you to use gflags as well.
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
 
     if (FLAGS_dir.empty() ||
         !butil::DirectoryExists(butil::FilePath(FLAGS_dir))) {
diff --git a/tools/rpc_view/rpc_view.cpp b/tools/rpc_view/rpc_view.cpp
index 51de9150..cdfb523d 100644
--- a/tools/rpc_view/rpc_view.cpp
+++ b/tools/rpc_view/rpc_view.cpp
@@ -82,13 +82,13 @@ public:
         const std::string* newtarget =
             server_cntl->http_request().uri().GetQuery("changetarget");
         if (newtarget) {
-            if (GFLAGS_NS::SetCommandLineOption("target", 
newtarget->c_str()).empty()) {
+            if (GFLAGS_NAMESPACE::SetCommandLineOption("target", 
newtarget->c_str()).empty()) {
                 server_cntl->SetFailed("Fail to change value of -target");
                 return;
             }
             target = *newtarget;
         } else {
-            if (!GFLAGS_NS::GetCommandLineOption("target", &target)) {
+            if (!GFLAGS_NAMESPACE::GetCommandLineOption("target", &target)) {
                 server_cntl->SetFailed("Fail to get value of -target");
                 return;
             }
@@ -153,15 +153,15 @@ public:
 };
 
 int main(int argc, char* argv[]) {
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     if (FLAGS_target.empty() &&
         (argc != 2 || 
-         GFLAGS_NS::SetCommandLineOption("target", argv[1]).empty())) {
+         GFLAGS_NAMESPACE::SetCommandLineOption("target", argv[1]).empty())) {
         LOG(ERROR) << "Usage: ./rpc_view <ip>:<port>";
         return -1;
     }
     // This keeps ad-hoc creation of channels reuse previous connections.
-    GFLAGS_NS::SetCommandLineOption("defer_close_second", "10");
+    GFLAGS_NAMESPACE::SetCommandLineOption("defer_close_second", "10");
 
     brpc::Server server;
     server.set_version("rpc_view_server");
diff --git a/tools/trackme_server/trackme_server.cpp 
b/tools/trackme_server/trackme_server.cpp
index 541f544a..76e09da9 100644
--- a/tools/trackme_server/trackme_server.cpp
+++ b/tools/trackme_server/trackme_server.cpp
@@ -88,7 +88,7 @@ private:
 };
 
 int main(int argc, char* argv[]) {
-    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
+    GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
     
     brpc::Server server;
     server.set_version("trackme_server");


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to