On 28/11/2017 09:34, Peter Maydell wrote: >> #define FMT_ERR "Error:%d" >> >> #define UINT8_P(ptr) ((uint8_t *) (ptr)) >> -#define UINT32_P(ptr) ((uint32_t *) (ptr)) >> +#define UINT32_P(ptr) ((uint32_t *) (size_t) (ptr)) >> #define PTR(var) UINT8_P(&var) > Hiding casts behind macros like this doesn't seem worthwhile > to me anyway -- all it's doing is obscuring what's going on. > And casting an arbitrary pointer to a uint32_t* is somewhat > alarming -- the alignment requirements may not be met. > Chances are high that code using that macro is not correct.
And also, we already have ldb_p and ldl_*_p that do exactly what you want (and give you an opportunity to specify the intended endianness, probably little-endian). Thanks, Paolo