静态函数的 DLL 导出
我有以下静态函数:
static inline HandVal
StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
我可以在 DLL 中导出该函数吗?如果是这样,怎么办?
谢谢,
Mike
背景信息:
我这样做是因为原始源代码附带一个 VS 项目,旨在编译为静态 (.lib) 库。为了使用 ctypes/Python,我将项目转换为 DLL。
我以 DLL 的形式启动了一个 VS 项目并导入了原始源代码。该项目构建为 DLL,但没有导出任何函数(包括上面列出的函数)(通过源代码中缺少 dllexport 和 DLL Export Viewer 等工具来确认)。我尝试遵循此处的一般建议(在header)无济于事...功能似乎仍然没有被导出。
I have the following static function:
static inline HandVal
StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
Can I export this function in a DLL? If so, how?
Thanks,
Mike
Background information:
I'm doing this because the original source code came with a VS project designed to compile as a static (.lib) library. In order to use ctypes/Python, I'm converting the project to a DLL.
I started a VS project as a DLL and imported the original source code. The project builds into a DLL, but none of the functions (including functions such as the one listed above) are exported (as confirmed by both the absence of dllexport in the source code and tools such as DLL Export Viewer). I tried to follow the general advice here (create an exportable wrapper function within the header) to no avail...functions still don't appear to be exported.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能从 DLL 中导出该函数。静态函数相当于该文件的私有函数。
您可以在文件中创建一个调用它的方法并将其导出。
You may not export that function from a DLL. static functions are equivalent to private to that file.
You can create a method in the file that calls it and export that.
通过使用静态和内联定义函数,您可以有效地保证它仅存在于包含该定义的模块中。
要么编辑每个文件以删除静态内联(这可能会破坏),要么更改所有内容以使用预处理器指令,该指令将允许您具有:
或
然后
或将一组包装器构建为单独的模块
By defining a function with static and inline you are effectively guaranteeing that it will be only in the modules that includes the definition.
Either edit each file to remove the static inline (which might break) or change everything to use a PreProcessor directive that will allow you to have either:
or
and then
or build a set of wrappers as a seperate module which does