[ell-i-developers] Re: PWM working for TIM2

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Fri, 31 Jan 2014 20:58:57 +0200

> #ifdef __cplusplus
> # define D32(p, r, v) { v }
> #else
> # ifndef offsetof
> #  define offsetof(st, m) ((uint32_t)(&((st *)0)->m))
> # endif
> # define D32(p, r, v) [offsetof(p, r)/sizeof(uint32_t)] = { v }
> #endif
> 
> As they are not supported in C++, my initial idea was to simply insert the 
> missing registers in between to simply use D32 homogeneously. 
> 
> Do you know of any other alternative for the designated initializers in C++?

No I don't, not really.  There is some discussion in the web on using C++11 
explicit initialisation lists and constexpr functions to construct the right 
initialisation list during compile time, but I haven't seen any such real life 
implementation.

--Pekka

Other related posts: