如何在 C 里面写一个 min ?但是这里的 x, y 会计算多次,那就写但就不能泛型了。起因:无意翻 linux 源码,看到找了定义继续翻看不懂,搜到,大受震撼。Linux Kernel's __is_constexpr MacroThe __is_constexpr(x) macro can be found in Linux Kernel's include/kernel/kernel.h: /* * This returns a constant expression while determining if an argument is * a constant expression, most importantly without evaluating the argument. * Glory to Martin Uecker */ #define __is_constexpr(x) \ (sizeof(int) == sizeof(*(8 ?https://stackoverflow.com/questions/49481217/linux-kernels-is-constexpr-macro以及__builtin_choose_exprOther Builtins (Using the GNU Compiler Collection (GCC))GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing of exceptions or variable-length argument lists and are not documented here because they may change from time to time; we do not recommend general use of these functions.https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html重点是 lazy 计算的。还差个于是去找 __PASTE 所以 __UNIQUE_ID 的作用是避免变量重名。搞这么复杂,还是早点上新语言吧。