我有两个 VS10 项目,一个是(不是 MFC)DLL。我想在 DLL 项目中使用在另一个项目的一个头文件中定义的 struct
。这些项目使用预编译头文件,所有包含文件都在 stdafx.h
下生成。
项目一
struct example
{
int a;
int b;
};
DLL 项目
#include "stdafx.h"
extern "C"
{
__declspec(dllexport) int ex(struct example *p)
{
int c = p->a;
return 1;
}
}
struct example
必须在 DLL 项目中可见。我怎样才能做到这一点?
最佳答案
这可以在编译时通过将 Struct 放在单独的头文件中并将其包含在两个项目中来解决。
关于c++ - 在两个 Visual Studio 2010 C++ 项目(DLL 和一个 Win32 项目)中共享头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374794/