From 8a3fedbcb8fc58dae8b43db3cae39688ec0332ef Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 25 Jan 2017 20:51:35 +0100 Subject: o i2c test o Misc other stuff. --- playground/include/playground.h | 29 ++++++++++++++++++++++++++--- playground/include/stm32f10x_conf.h | 6 ++++++ 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'playground') diff --git a/playground/include/playground.h b/playground/include/playground.h index 168c5c5..3e1b4bc 100644 --- a/playground/include/playground.h +++ b/playground/include/playground.h @@ -13,11 +13,34 @@ int main(); extern "C" void Default_Handler(); +#include +#include +#include + // TODO: replace with std::extent<>; http://en.cppreference.com/w/cpp/types/extent -template +//template +//static inline constexpr +//std::size_t SizeOfArray(const T(&)[N]) { +// return N; +//} + +/* +namespace { + template struct identity { using type = T; }; +} +template +static inline constexpr +typename identity::type SizeOfArray(const T(&)[N]) { + static_assert(std::numeric_limits::max() >= N, "N does not fit in R"); + return static_cast(N); +} +*/ + +template static inline constexpr -size_t SizeOfArray(const T(&)[N]) { - return N; +R SizeOfArray(const T(&)[N]) { + static_assert(std::numeric_limits::max() >= N, "N does not fit in R"); + return static_cast(N); } #endif diff --git a/playground/include/stm32f10x_conf.h b/playground/include/stm32f10x_conf.h index f663d12..8c49c5e 100644 --- a/playground/include/stm32f10x_conf.h +++ b/playground/include/stm32f10x_conf.h @@ -30,7 +30,13 @@ #ifdef USE_FULL_ASSERT #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +#ifdef __cplusplus +extern "C" { +#endif void assert_failed(uint8_t* file, uint32_t line); +#ifdef __cplusplus +} +#endif #else #define assert_param(expr) ((void)0) #endif -- cgit v1.2.3