“清除”宏是否导出到 .lib 文件?
我有一些宏,例如#define dosomething(x) some(x)
,它被编译成 dll。我会在构建创建的库中拥有该宏吗?
I have some macros like,#define dosomething(x) something(x)
and it is compiled into a dll. Will I have that macro in that lib created by the build?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不。
编译器甚至看不到宏。它们在预处理期间被替换文本替换,这发生在最开始的时候。宏是愚蠢的,它们对你或你的动机一无所知。他们甚至不知道你在写什么语言。提防!
No.
Macros aren't even visible to the compiler. They get replaced by their substitution text during preprocessing, which happens at the very beginning. Macros are dumb, they know nothing about you or your motives. They don't even know what language you're writing. Beware!
不。
宏只是源代码级别的(不那么)详细的复制粘贴工具。它们在编译之前进行扩展,并且编译器不知道它们的存在。
如果您希望在库中导出
dosomething
符号,则必须将其声明为函数。No.
Macros are just a (not so) elaborated copy pasting device at the source code level. They are expanded before compilation, and the compiler isn't aware of their existence.
If you want the
dosomething
symbol to be exported in your library, you have to declare it as a function.宏仅由预处理器使用和处理。编译器不使用它们,链接器根本不知道它们。所以,答案是否定的。不导出宏。
你需要什么?你不能只
#include
给定头文件吗?Macros are used and processed by pre-processor only. They aren't used by compiler and not at all known by the linker. So, the answer is NO. Macros are not exported.
What do you need? Can't you just
#include
given header file?