add Wdouble-promotion warning

This commit is contained in:
Oskar Weigl
2018-09-26 22:07:47 -07:00
parent 63d8ecffe1
commit 7776d39cd0
3 changed files with 21 additions and 7 deletions
+3
View File
@@ -3,6 +3,9 @@ Please add a note of your changes below this heading if you make a Pull Request.
# Unreleased
### Added
* -Wdouble-promotion warning to compilation
### Changed
* Make python tools compatible with python 2.7 (so it can be used with ROS)
* Threading API constructor can't take the daemon parameter, so all thread creation had to be expanded out.
+1 -1
View File
@@ -89,7 +89,7 @@ FLAGS += '-mthumb'
FLAGS += '-mcpu=cortex-m4'
FLAGS += '-mfpu=fpv4-sp-d16'
FLAGS += '-mfloat-abi=hard'
FLAGS += { '-Wall', '-Wfloat-conversion', '-fdata-sections', '-ffunction-sections'}
FLAGS += { '-Wall', '-Wdouble-promotion', '-Wfloat-conversion', '-fdata-sections', '-ffunction-sections'}
-- debug build
FLAGS += '-g -gdwarf-2'
+17 -6
View File
@@ -592,10 +592,10 @@ private:
template<typename T>
struct format_traits_t;
template<> struct format_traits_t<float> { using type = void;
static constexpr const char * fmt = "%f";
static constexpr const char * fmtp = "%f";
};
// template<> struct format_traits_t<float> { using type = void;
// static constexpr const char * fmt = "%f";
// static constexpr const char * fmtp = "%f";
// };
template<> struct format_traits_t<int32_t> { using type = void;
static constexpr const char * fmt = "%ld";
static constexpr const char * fmtp = "%ld";
@@ -626,8 +626,15 @@ static bool to_string(const T& value, char * buffer, size_t length, int) {
snprintf(buffer, length, format_traits_t<T>::fmtp, value);
return true;
}
// Special case for float because printf promotes float to double, and we get warnings
template<typename T>
static bool to_string(const float& value, char * buffer, size_t length, int) {
snprintf(buffer, length, "%f", (double)value);
return true;
}
template<typename T>
//__attribute__((__unused__))
static bool to_string(const bool& value, char * buffer, size_t length, int) {
buffer[0] = value ? '1' : '0';
buffer[1] = 0;
@@ -642,7 +649,11 @@ template<typename T, typename = typename format_traits_t<T>::type>
static bool from_string(const char * buffer, size_t length, T* property, int) {
return sscanf(buffer, format_traits_t<T>::fmt, property) == 1;
}
//__attribute__((__unused__))
// Special case for float because printf promotes float to double, and we get warnings
template<typename T>
static bool from_string(const char * buffer, size_t length, float* property, int) {
return sscanf(buffer, "%f", property) == 1;
}
template<typename T>
static bool from_string(const char * buffer, size_t length, bool* property, int) {
int val;