例如,我想做这样的事情:#define MACRO(name) #include "name##foo"并按以下方式使用它:MACRO(Test)这将扩展为:#include "Testfoo"谦虚的#号导致预处理器发出响声. MinGW给我以下错误: '#' is not followed by a macro parameter我想我需要转义#号,但是即使有可能我也不需要.是的,宏确实是邪恶的... 解决方案据我所知,您不能在define中使用另一个预处理程序指令.Without going into the gory details I want to use a #define macro that will expand to a #include but the '#' sign is confusing the preprocessor (as it thinks I want to quote an argument.)For example, I want to do something like this:#define MACRO(name) #include "name##foo"And use it thus:MACRO(Test)Which will expand to:#include "Testfoo"The humble # sign is causing the preprocessor to barf. MinGW gives me the following error:'#' is not followed by a macro parameterI guess I need to escape the # sign but I don't if this is even possible.Yes, macros are indeed evil... 解决方案 As far as I remember you cannot use another preprocessor directive in define. 这篇关于在#define宏中转义#符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!