定义导出的问题

发布于 2024-12-05 02:55:41 字数 603 浏览 2 评论 0原文

我正在尝试在 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 技术交流群。

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

发布评论

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

评论(1

无敌元气妹 2024-12-12 02:55:41

将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).

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