1

I got this massive project with many classes with definitions in dll files. I need to extract a part of this project and create a new project from that part. I have managed to find some dll files by using the Code Map in Visual Studio but some classes are not shown up there.

#   ifdef FCBase
#       define BaseExport  __declspec(dllexport)
#   else
#       define BaseExport  __declspec(dllimport)
#   endif

class BaseExport Handled
{.
 .
};

What is specifying which dll files are linked to what?

4

1 回答 1

1

指令__declspec(dllexport)指示使用该指令声明的任何内容都将从 DLL 导出,以用于链接到该 DLL 的其他应用程序。因此,当为将被编译成 DLL 的代码编写头文件时,函数声明和类定义都使用该指令进行修饰。另一方面,将使用这些函数和类的代码需要用 声明它们__declspec(dllimport),以让链接器知道它们将从 DLL 导入。

这两个指令通常由单个宏替换,该宏根据项目设置解析为适当的值。这样,您可以在 DLL 实现文件和将使用此 DLL 的其他应用程序的实现文件中包含相同的头文件。例如,在您的情况下,DLL 的项目将已FCBase定义,因此BaseExport__declspec(dllexport)在预处理步骤期间解析。这表明这个项目是为了实现 DLL。未定义的项目FCBase,这意味着该项目正在从 DLL 中导入类函数。

于 2015-11-17T11:26:53.770 回答