From 7dc646398064cdf7ca1e636edd285f73ea69592f Mon Sep 17 00:00:00 2001 From: Kai Li Date: Sat, 9 Aug 2014 20:11:38 +0800 Subject: [PATCH] Fix the gflags namespace issue --- include/caffe/common.hpp | 10 ++++++++++ src/caffe/common.cpp | 14 +------------- tools/caffe.cpp | 1 - 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/caffe/common.hpp b/include/caffe/common.hpp index 97a3496..9008eae 100644 --- a/include/caffe/common.hpp +++ b/include/caffe/common.hpp @@ -2,6 +2,7 @@ #define CAFFE_COMMON_HPP_ #include +#include #include #include @@ -11,6 +12,15 @@ #include "caffe/util/device_alternate.hpp" +// gflags 2.1 issue: namespace google was changed to gflags without warning. +// Luckily we will be able to use GFLAGS_GFAGS_H_ to detect if it is version +// 2.1. If yes , we will add a temporary solution to redirect the namespace. +// TODO(Yangqing): Once gflags solves the problem in a more elegant way, let's +// remove the following hack. +#ifndef GFLAGS_GFLAGS_H_ +namespace gflags = google; +#endif // GFLAGS_GFLAGS_H_ + // Disable the copy and assignment operator for a class. #define DISABLE_COPY_AND_ASSIGN(classname) \ private:\ diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp index 99b2292..e6c0a4f 100644 --- a/src/caffe/common.cpp +++ b/src/caffe/common.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,17 +5,6 @@ #include "caffe/common.hpp" #include "caffe/util/rng.hpp" -// gflags 2.1 issue: namespace google was changed to gflags without warning. -// Luckily we will be able to use GFLAGS_GFAGS_H_ to detect if it is version -// 2.1. If yes , we will add a temporary solution to redirect the namespace. -// TODO(Yangqing): Once gflags solves the problem in a more elegant way, let's -// remove the following hack. -#ifdef GFLAGS_GFLAGS_H_ -namespace google { -using ::gflags::ParseCommandLineFlags; -} // namespace google -#endif // GFLAGS_GFLAGS_H_ - namespace caffe { shared_ptr Caffe::singleton_; @@ -44,7 +32,7 @@ int64_t cluster_seedgen(void) { void GlobalInit(int* pargc, char*** pargv) { // Google flags. - ::google::ParseCommandLineFlags(pargc, pargv, true); + ::gflags::ParseCommandLineFlags(pargc, pargv, true); // Google logging. ::google::InitGoogleLogging(*(pargv)[0]); } diff --git a/tools/caffe.cpp b/tools/caffe.cpp index 22d9eb1..13398ae 100644 --- a/tools/caffe.cpp +++ b/tools/caffe.cpp @@ -1,4 +1,3 @@ -#include #include #include -- 2.7.4