X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=utils.h;h=019d817fed5f3b3c8ae80902114635cc674b3dec;hp=b64b40088acdddc7cb0063be8af535c2f93d39d6;hb=HEAD;hpb=ace64897d47b9bc7af277d8a3f8a0ff67976cba8 diff --git a/utils.h b/utils.h index b64b400..019d817 100644 --- a/utils.h +++ b/utils.h @@ -127,9 +127,18 @@ int clock_gettime(int type, struct timespec *tv); #define __eval_once(func, x) \ ({ __typeof__(x) __x = x; func(__x); }) +#ifdef __cplusplus +/* + * g++ does not support __builtin_choose_expr, so always use __eval_once. + * Unfortunately this means that the byte order functions can't be used + * as a constant expression anymore + */ +#define __eval_safe(func, x) __eval_once(func, x) +#else #define __eval_safe(func, x) \ __builtin_choose_expr(__is_constant(x), \ func(x), __eval_once(func, x)) +#endif #if __BYTE_ORDER == __LITTLE_ENDIAN