The name basically talks about this, but I'm especially interested in knowing whether to expect the next (slightly offensive) macro to work (with C99 or higher), that is, it will return a pointer to the actual partition allocated by the memory stack based on the size of the expression:
#include <stdint.h>
#define NASTY(expr) ( \
8 == sizeof(expr) ? (void *)(&(uint64_t){(expr)}) : \
( \
4 == sizeof(expr) ? (void *)(&(uint32_t){(expr)}) : \
( \
2 == sizeof(expr) ? (void *)(&(uint16_t){(expr)}) : (void *)(&(uint8_t){(expr)}) \
) \
) \
)
EDIT:
The reason I am interested in such a macro is (1) I am aer nerd and (2) I am writing several macro-generating macros for an embedded application that require a dynamic memcpyexpression result (such as x*y+z). We work in an energy-sensitive application where a function causes matter.
gdoug source
share