[Positioner] Allow building with clang++

This patch is to have clang++ (>= 3.2) happily build OwlPS Positioner.
For some reason it doesn't work on NetBSD, but it is fine on GNU/Linux
and (a couple of warnings apart) on DragonFly BSD.
This commit is contained in:
Matteo Cypriani 2013-06-06 17:07:22 -04:00
parent d32813376b
commit 9701a2d393
6 changed files with 51 additions and 29 deletions

View File

@ -177,26 +177,38 @@ endif()
## Positioner ##
# OwlPS Positioner can be built only with GCC, and with a minimal
# version. CMAKE_CXX_COMPILER_VERSION is not guaranteed to be set,
# so we will test GCC's version number only if possible.
# OwlPS Positioner can be built only with a minimal version of GCC, or
# Clang++. CMAKE_CXX_COMPILER_VERSION is not guaranteed to be set, so we
# will test the version number only if possible.
set(POSITIONER_MIN_GCC_VERSION 4.7)
if (CMAKE_COMPILER_IS_GNUCXX)
set(POSITIONER_MIN_CLANG_VERSION 3.2)
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU) # Are we using GCC?
# Test the compiler version if we can
if (${CMAKE_CXX_COMPILER_VERSION})
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL ${POSITIONER_MIN_GCC_VERSION} OR
${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER ${POSITIONER_MIN_GCC_VERSION})
add_subdirectory(owlps-positioner)
else() # GCC's version is too low
message(WARNING
"OwlPS Positioner requires GCC >= ${POSITIONER_MIN_GCC_VERSION}")
endif()
else() # we couldn't get GCC's version, let's try to build anyway
if (${CMAKE_CXX_COMPILER_VERSION} AND
${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS ${POSITIONER_MIN_GCC_VERSION})
# GCC's version is too low
message(WARNING
"OwlPS Positioner requires GCC >= ${POSITIONER_MIN_GCC_VERSION}")
else()
# GCC's version is OK or we couldn'd get it
add_subdirectory(owlps-positioner)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL Clang) # Are we using Clang?
if (${CMAKE_CXX_COMPILER_VERSION} AND
${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS ${POSITIONER_MIN_CLANG_VERSION})
# Clang's version is too low
message(WARNING
"OwlPS Positioner requires GCC >= ${POSITIONER_MIN_GCC_VERSION}")
else()
# Clang's version is OK or we couldn'd get it
add_subdirectory(owlps-positioner)
endif()
else() # we're not using GCC
message(WARNING
"OwlPS Positioner requires GCC (>= ${POSITIONER_MIN_GCC_VERSION})")
"OwlPS Positioner requires GCC (>= ${POSITIONER_MIN_GCC_VERSION}) or Clang (>= ${POSITIONER_MIN_CLANG_VERSION})")
endif()
## UDP-to-HTTP ##

View File

@ -17,7 +17,8 @@ systems” below) with the following development libraries installed:
You also need support for POSIX threads, which should be provided by
default by your system in most cases, and the GCC C++ compiler (g++)
version 4.7 or above.
version 4.7 or above; the Clang C++ compiler (clang++) version 3.2 or
above should also work in most cases.
If you miss one or more of the requirements, the concerned modules will
not be built, but the others can still be.

View File

@ -20,7 +20,7 @@
CalibrationRequest::
CalibrationRequest(uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION):
CalibrationRequest(uint_fast8_t _type):
reference_point(NULL), direction(Direction())
{
type = _type ;

View File

@ -30,7 +30,7 @@ protected:
Direction direction ;
public:
CalibrationRequest(uint_fast8_t _type) ;
CalibrationRequest(uint_fast8_t _type = OWL_REQUEST_AUTOCALIBRATION) ;
CalibrationRequest(const CalibrationRequest &source):
Request(source), reference_point(source.reference_point),

View File

@ -54,20 +54,29 @@ protected:
void clear_real_position(void) ;
//@}
/// Measurements' list type
/**
* This really is just an alias to work-around clang++ that doesn't
* handle the following syntax:
*
* Request(..., const std::unordered_map<std::string, Measurement>
* &_measurements = std::unordered_map<std::string,
* Measurement>()) ;
*/
typedef std::unordered_map<std::string, Measurement> measurements_list ;
public:
Request(const Mobile *_mobile = NULL,
const Timestamp &_time_sent = Timestamp(),
const std::unordered_map<std::string, Measurement>
&_measurements =
std::unordered_map<std::string, Measurement>()) ;
&_measurements = measurements_list()) ;
Request(const std::unordered_map<std::string, Measurement>
&_measurements) ;
Request(const Timestamp &_time_sent,
const std::unordered_map<std::string, Measurement>
&_measurements =
std::unordered_map<std::string, Measurement>()) ;
&_measurements = measurements_list()) ;
Request(const Request &source) ;

View File

@ -37,10 +37,10 @@ protected:
float trx_power ; ///< Transmit power in dBm
public:
WifiDevice(const std::string &_ip_addr,
const std::string &_mac_addr,
const float _antenna_gain,
const float _trx_power) ;
WifiDevice(const std::string &_ip_addr = "",
const std::string &_mac_addr = "",
const float _antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER) ;
WifiDevice(const WifiDevice &source):
ip_addr(source.ip_addr), mac_addr(source.mac_addr),
@ -81,10 +81,10 @@ public:
inline WifiDevice::
WifiDevice(const std::string &_ip_addr = "",
const std::string &_mac_addr = "",
const float _antenna_gain = WIFIDEVICE_DEFAULT_ANTENNA_GAIN,
const float _trx_power = WIFIDEVICE_DEFAULT_TRX_POWER):
WifiDevice(const std::string &_ip_addr,
const std::string &_mac_addr,
const float _antenna_gain,
const float _trx_power):
ip_addr(_ip_addr), mac_addr(_mac_addr),
antenna_gain(_antenna_gain), trx_power(_trx_power)
{