“清除”宏是否导出到 .lib 文件?

发布于 2024-11-29 00:09:06 字数 91 浏览 0 评论 0原文

我有一些宏,例如
#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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半步萧音过轻尘 2024-12-06 00:09:07

不。

编译器甚至看不到宏。它们在预处理期间被替换文本替换,这发生在最开始的时候。宏是愚蠢的,它们对你或你的动机一无所知。他们甚至不知道你在写什么语言。提防!

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!

策马西风 2024-12-06 00:09:07

不。

宏只是源代码级别的(不那么)详细的复制粘贴工具。它们在编译之前进行扩展,并且编译器不知道它们的存在。

如果您希望在库中导出 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.

思慕 2024-12-06 00:09:07

宏仅由预处理器使用和处理。编译器不使用它们,链接器根本不知道它们。所以,答案是否定的。不导出宏。

你需要什么?你不能只 #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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文