Edit 2:I was thinking about alternatives that do not need an external tools. Maybe it is not needed to declare it as macro? If we assume WhatsThat() is returning int, it is not forbidden to write int PROTOTYPENAMED(ANOTHERFUNCTION) = WhatsThat();.推荐答案不适用于标准C/C ++预处理器.但是,您可以使用某些C ++或C源代码生成器(例如,例如 GPP 或 GNU m4 预处理程序或某些脚本-eg在Python中,您的 awk , guile ,...-(或程序).Not doable with the standard C/C++ preprocessor. However, you might feed your compiler using some C++ or C source generator, like e.g. the GPP or the GNU m4 preprocessors, or some script -e.g. in Python, awk, guile, ...- (or program) of yours. 例如, yacc 或野牛和 ANTLR 生成C ++代码.并且 MELT 被编译为C ++代码.For example, yacc or bison and ANTLR generate C++ code. And MELT is compiled into C++ code.当然,您需要相应地配置构建器,例如添加更多 GNU make 规则.Of course, you need to configure your builder accordingly, e.g. add some more GNU make rules. 这篇关于为另一个宏生成名称(C预处理程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 23:27