Merge pull request #891 from kloudkl/gflags_namespace

Fix the gflags namespace issue
This commit is contained in:
Evan Shelhamer 2014-08-09 14:20:44 -07:00
Родитель cfdf7af338 148eb67d66
Коммит 78bac712fa
3 изменённых файлов: 11 добавлений и 14 удалений

Просмотреть файл

@ -2,6 +2,7 @@
#define CAFFE_COMMON_HPP_
#include <boost/shared_ptr.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <cmath>
@ -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:\

Просмотреть файл

@ -1,4 +1,3 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <cstdio>
#include <ctime>
@ -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> 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]);
}

Просмотреть файл

@ -1,4 +1,3 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <cstring>