Tag: decorator

编译时的C函数装饰器(包装器)

我试图在预处理器的帮助下改变C中某些函数的行为; 并添加可以打开或关闭的可选参数… 可选参数的基本模式很简单: #ifdef OPT_PARAM #define my_func(a, b, opt) _my_func(a, b, opt) #else #define my_func(a, b, opt) _my_func(a, b) #endif /*the rest of the code always calls “my_func” with all the params and not the underscored version…*/ #ifdef OPT_PARAM void _my_func(int a, int b, int opt) #else void _my_func(int a, int b) #endif { /*… […]