mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 06:33:33 +08:00
Proper C++ version detection
This commit is contained in:
@@ -16,6 +16,21 @@
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
/**
|
||||
* UAVCAN can be compiled in C++11 mode.
|
||||
* This macro allows to detect which version of the C++ standard is being used.
|
||||
*/
|
||||
#define UAVCAN_CPP11 2011
|
||||
#define UAVCAN_CPP03 2003
|
||||
|
||||
#if __cplusplus > 201200
|
||||
# error Unsupported C++ standard
|
||||
#elif (__cplusplus > 201100) || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define UAVCAN_CPP_VERSION UAVCAN_CPP11
|
||||
#else
|
||||
# define UAVCAN_CPP_VERSION UAVCAN_CPP03
|
||||
#endif
|
||||
|
||||
/**
|
||||
* UAVCAN can be explicitly told to ignore exceptions, or it can be detected automatically.
|
||||
*/
|
||||
|
||||
@@ -8,12 +8,16 @@
|
||||
#include <limits>
|
||||
#include <uavcan/data_type.hpp>
|
||||
#include <uavcan/util/compile_time.hpp>
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
#include <uavcan/marshal/type_util.hpp>
|
||||
#include <uavcan/marshal/integer_spec.hpp>
|
||||
#if __cplusplus > 201100
|
||||
# include <cmath>
|
||||
#else
|
||||
# include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#ifndef UAVCAN_CPP_VERSION
|
||||
# error UAVCAN_CPP_VERSION
|
||||
#endif
|
||||
#if UAVCAN_CPP_VERSION < UAVCAN_CPP11
|
||||
# include <math.h> // Needed for isfinite()
|
||||
#endif
|
||||
|
||||
namespace uavcan
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include <uavcan/fatal_error.hpp>
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
|
||||
#ifndef UAVCAN_CPP_VERSION
|
||||
# error UAVCAN_CPP_VERSION
|
||||
#endif
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
@@ -31,7 +35,7 @@ class LazyConstructor
|
||||
|
||||
template <typename U> struct ParamType { typedef const U& Type; };
|
||||
template <typename U> struct ParamType<U&> { typedef U& Type; };
|
||||
#if __cplusplus > 201100
|
||||
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||
template <typename U> struct ParamType<U&&> { typedef U&& Type; };
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user