内联类在多个项目中调用非内联函数 [英] Having inline class call non-inline functions in multiple projects

查看:191
本文介绍了内联类在多个项目中调用非内联函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多项目解决方案,我正在使用我自己的智能指针。为此,我的智能指针使用泛型编程,因此必须内联。


最低级别的DLL是我定义智能指针的地方,它们都使用中央表来维护引用各种对象。该DLL现在编译。


但是,当我尝试编译第二个使用第一个DLL的DLL时,我收到一系列链接错误(LNK 2001,2019,导致1120 )。



在我的第一个DLL中,我有以下代码来管理输入和导出:

 #pragma once 
#ifndef _TREC_LIB_DLL
#define _TREC_LIB_DLL __declspec(dllexport)
#else
#define _TREC_LIB_DLL __declspec(dllimport)
#endif

然后我会使用这个宏在较低的DLL中声明类,这将使它们在更高级别的DLL中可用,并且设置到目前为止运行良好。


但是,在较低级别的DLL中,我介绍了一些帮助管理智能指针表的函数。头文件在这里:

 #pragma once 
#pragma
#include" TObject.h"


// extern"C" //
// {
_TREC_LIB_DLL void * Get(unsigned short index,unsigned char time);
_TREC_LIB_DLL void删除(无符号短索引);
_TREC_LIB_DLL void DeReference(unsigned short index);
_TREC_LIB_DLL int InsertNewReference(void * ref,unsigned char details);

//}

这些是在较低的DLL项目中的cpp文件中实现的。我的目标是使它们成为_decl规范,这样当这些函数在较低的库中编译时,它们将在生成的.lib文件中被引用,并且当
编译第二个DLL时将成为_declspec(dllimport)。 / p>

第二个DLL可以访问第一个DLL的.lib文件。



最后,智能指针会调用这些函数,它们自己的方法是内联的,只有一个DLL没有问题。但是,当在第二个DLL的链接阶段请求这些函数时,会发生这些链接错误。 






解决方案

什么是这个问题?我不明白你在寻求帮助。


I have a multi-project solution and I'm using my own smart pointers for them. To do so, my smart pointers are using generic programming and thus have to be inline.

The lowest level DLL is where I have my smart pointers defined and they all use a central table to maintain references to various objects. That DLL compiles now.

However, When I attempt to compile a second DLL that uses the first DLL, I'm getting a series of Linking errors (LNK 2001, 2019, leading to 1120).

In my first DLL, I have the following code to manage inports and exports:

#pragma once
#ifndef _TREC_LIB_DLL
#define _TREC_LIB_DLL __declspec(dllexport)
#else
#define _TREC_LIB_DLL __declspec(dllimport)
#endif

I would then declare classes in lower DLLs with this macro which would make them usable in higher level DLLs and the set up has worked well so far.

However, in the lower level DLL, I introduced some functions to help manage the smart pointer tables. The header file is here:

#pragma once
#pragma 
#include "TObject.h"


//extern "C" // 
//{
	_TREC_LIB_DLL void* Get(unsigned short index, unsigned char time);
	_TREC_LIB_DLL void Delete(unsigned short index);
	_TREC_LIB_DLL void DeReference(unsigned short index);
	_TREC_LIB_DLL int InsertNewReference(void* ref, unsigned char details);

//}

These are implemented in a cpp file in the lower DLL project. My goal was to make them _decl spec such that when these functions are compiled in the lower library, they'll be referenced in the resulting .lib file and will become _declspec(dllimport) when the second DLL is compiled.

The second DLL does have access to the .lib file of the first DLL.

Finally, the smart pointers do call these functions and their own methods are inline and there is no problem just the one DLL. But when these functions are requested during the linking stage of the second DLL, these Linking errors occur. 

解决方案

What is the question? I don't understand what you are asking for help with.


这篇关于内联类在多个项目中调用非内联函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆