定义导出的问题
我正在尝试在 VC++ 2008 中构建动态 DLL,现在在 .h 文件中,我声明以下内容
#ifndef PREFILTER_LIBRARY_H
#define PREFILTER_LIBRARY_H
#ifdef PREFILTER_EXPORTS
# define PREFILTER_API __declspec(dllexport)
#else
# define PREFILTER_API __declspec(dllimport)
#endif
#endif
在我正在编写的 PreFilter.h 文件中
class PREFILTER_API PreFilter
{
...
};
问题是我不断收到:
warning C4273: 'PreFilter::Apply' : inconsistent dll linkage
我看到上述宏的 dllexport 部分没有突出显示并被注释,这应该是相反的,加上我有另一个包含 Apply() 方法的 .h 文件。
无法弄清楚我在这里做错了什么。我正在尝试导出 PreFilter.h 的函数
I am trying to build a Dynamic DLL in VC++ 2008, now in a .h file, I declare the following
#ifndef PREFILTER_LIBRARY_H
#define PREFILTER_LIBRARY_H
#ifdef PREFILTER_EXPORTS
# define PREFILTER_API __declspec(dllexport)
#else
# define PREFILTER_API __declspec(dllimport)
#endif
#endif
While in the PreFilter.h file I am writing
class PREFILTER_API PreFilter
{
...
};
The problem is I keep getting:
warning C4273: 'PreFilter::Apply' : inconsistent dll linkage
I see that the dllexport part of the above macros is not highlighted and is commented which should have been the other way around, plus I have another .h file that contains Apply() method.
Can't figure out what I am doing wrong here. I am trying to export the functions of PreFilter.h
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将PREFILTER_EXPORTS添加到Dll项目设置中的预处理器常量列表中:项目-属性-配置属性-C++-预处理器-预处理器定义。
当该文件在Dll项目中使用时,项目中定义了PREFILTER_EXPORTS,PREFILTER_API扩展为__declspec(dllexport)。在任何其他未定义 PREFILTER_EXPORTS 的项目中,PREFILTER_API 都会扩展为 __declspec(dllimport)。
Add PREFILTER_EXPORTS to the list of preprocessor constants in Dll project settings: Project - Properties - Configuration Properties - C++ - Preprocessor - Preprocessor definitions.
When this file is used in Dll project, PREFILTER_EXPORTS is defined in the project, and PREFILTER_API is expanded as __declspec(dllexport). In any other project, where PREFILTER_EXPORTS is not defined, PREFILTER_API is expanded as __declspec(dllimport).