From 4e838de2b933643881106567b1efcd3c806c6557 Mon Sep 17 00:00:00 2001 From: wyy Date: Thu, 7 Nov 2013 04:36:36 -0800 Subject: [PATCH] make cmakefile to compatiable with g++-4.6 and 4.7 --- CMakeLists.txt | 1 + src/Husky/ServerFrame.cpp | 2 +- src/Limonp/map_functs.hpp | 75 +------------------------------------ src/Limonp/std_outbound.hpp | 6 +-- 4 files changed, 7 insertions(+), 77 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8983dc2..fd7a59e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,2 +1,3 @@ PROJECT(CPPJIEBA) +ADD_DEFINITIONS(-std=c++0x -O3) ADD_SUBDIRECTORY(src) diff --git a/src/Husky/ServerFrame.cpp b/src/Husky/ServerFrame.cpp index aa3eab9..2672e64 100644 --- a/src/Husky/ServerFrame.cpp +++ b/src/Husky/ServerFrame.cpp @@ -213,7 +213,7 @@ namespace Husky addrSock.sin_port=htons(nPort); addrSock.sin_addr.s_addr=htonl(INADDR_ANY); int retval; - retval=bind(sock,(sockaddr*)&addrSock,sizeof(sockaddr)); + retval = ::bind(sock,(sockaddr*)&addrSock,sizeof(sockaddr)); if(SOCKET_ERROR==retval) { LogError("error [%s]", strerror(errno)); diff --git a/src/Limonp/map_functs.hpp b/src/Limonp/map_functs.hpp index 44d472c..747f130 100644 --- a/src/Limonp/map_functs.hpp +++ b/src/Limonp/map_functs.hpp @@ -12,84 +12,13 @@ #include #include -#include -#define HashMap std::tr1::unordered_map +#include +#define HashMap std::unordered_map namespace Limonp { using namespace std; - - //template - // string setToString(const set& st) - // { - // if(st.empty()) - // { - // return "{}"; - // } - // stringstream ss; - // ss<<'{'; - // typename set::const_iterator it = st.begin(); - // ss<<*it; - // it++; - // while(it != st.end()) - // { - // ss<<", "<<*it; - // it++; - // } - // ss<<'}'; - // return ss.str(); - // } - - //template - // string mapToString(const map& mp) - // { - // if(mp.empty()) - // { - // return "{}"; - // } - // stringstream ss; - // ss<<'{'; - // typename map::const_iterator it = mp.begin(); - // ss<first<<": "<second; - // it++; - // while(it != mp.end()) - // { - // ss<<", "<first<<": "<second; - // it++; - // } - // ss<<'}'; - // return ss.str(); - // } - - //template - // string HashMapToString(const HashMap& mp) - // { - // if(mp.empty()) - // { - // return "{}"; - // } - // stringstream ss; - // ss<<'{'; - // typename HashMap::const_iterator it = mp.begin(); - // ss<first<<": "<second; - // it++; - // while(it != mp.end()) - // { - // ss<<", "<first<<": "<second; - // it++; - // } - // ss<<'}'; - // return ss.str(); - // } - //template - // string pairToString(const pair& p) - // { - // stringstream ss; - // ss< vT getMap(const map& mp, const kT & key, const vT & defaultVal) { diff --git a/src/Limonp/std_outbound.hpp b/src/Limonp/std_outbound.hpp index ab3e5c3..0085704 100644 --- a/src/Limonp/std_outbound.hpp +++ b/src/Limonp/std_outbound.hpp @@ -1,7 +1,7 @@ #ifndef LIMONP_STD_OUTBOUND_H #define LIMONP_STD_OUTBOUND_H -#include +#include "map_functs.hpp" #include #include @@ -59,14 +59,14 @@ namespace std return os; } template - ostream& operator << (ostream& os, const std::tr1::unordered_map& mp) + ostream& operator << (ostream& os, const HashMap& mp) { if(mp.empty()) { return os << "{}"; } os<<'{'; - typename std::tr1::unordered_map::const_iterator it = mp.begin(); + typename HashMap::const_iterator it = mp.begin(); os<<*it; it++; while(it != mp.end())