hartmannathan commented on code in PR #7028: URL: https://github.com/apache/incubator-nuttx/pull/7028#discussion_r964830723
########## include/nuttx/nuttx.h: ########## @@ -48,4 +48,83 @@ #define container_of(ptr, type, member) \ ((type *)((uintptr_t)(ptr) - offsetof(type, member))) +/* Name: max_t + * + * Description: + * return maximum of two values, using the specified type + * + * Arguments: + * type - data type to use + * x - first value + * y - second value + */ + +#ifndef max_t +#define max_t(type, x, y) ({ \ + type _max1 = (x); \ + type _max2 = (y); \ + _max1 > _max2 ? _max1 : _max2; }) Review Comment: We need to honor C89 standard since NuttX supports architectures that use C89 compilers without support for C99 and up. I wonder what is the motivation for adding these macros? Is it for use in NuttX common code? I understand that the ordinary min() and max() macros evaluate their arguments more than once and the above max_t() evaluates each argument once; but do we really need this for use within NuttX? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org