使用#define在C ++ / C中包含另一个文件 [英] Using #define to include another file in C++/C
本文介绍了使用#define在C ++ / C中包含另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要定义一个包含另一个头文件的宏,如下所示:
I want to define a macro which includes another header file like so:
#define MY_MACRO (text) #include "__FILE__##_inline.inl"
这样,当预处理器解析文件person.h,MY_MACRO(blahblah )扩展为
So that when the preprocessor parses file person.h, MY_MACRO(blahblah) expands to
#includeperson.h.inline.inl
#include "person.h.inline.inl"
任何提示这个?
any hints on how to do this ?
推荐答案
不可能使用 #define
但是在你的情况下,即使运行预处理程序两次也不会有帮助,因为 #include > code>必须是
...
或< ...> $ c $形式的单个字符串c>。
But in your case even running the preprocessor twice won't help because the #include
must be a single string of the form "..."
or <...>
.
这篇关于使用#define在C ++ / C中包含另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文