动态typedef [英] dynamic typedef

查看:82
本文介绍了动态typedef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个有点愚蠢的问题:是否有可能做一个动态的

typedef然后再使用它?


void createTypedef(std :: string name){

typedef name;

}


我的想法是动态生成函数指针,即在
运行时期间,这样我就可以调用插件中的函数,这些函数在编译时我不知道

,但是它们是以XML文件形式发送的,伴随着/ b $ b dll / so?!

任何想法都受到热烈赞赏!

干杯,

Simon

Hi,

I got a somewhat stupid question: Is it possible to do a dynamic
typedef and then use it afterwards ?

void createTypedef(std::string name){
typedef name;
}

The idea is to generate function pointers on the fly, i.e. during
runtime, so that I can call functions in plugins that I''m not aware of
at compile time, but they get delivered in a XML file accompagnying
the dll/so ?!
Any ideas are warmly appreciated!
Cheers,
Simon

推荐答案

2004-04-18,Simon Moser< Si ****** ***@gmx.de>写道:
On 2004-04-18, Simon Moser <Si*********@gmx.de> wrote:



我有一个有点愚蠢的问题:是否有可能做一个动态的
typedef,然后再使用它? br />
void createTypedef(std :: string name){
typedef name;
}


no

我的想法是动态生成函数指针,即在运行时,这样我就可以在编译时调用我不了解的插件中的函数,但是它们是以XML格式传递的。文件伴随
dll / so?!
任何想法都受到热烈赞赏!

Hi,

I got a somewhat stupid question: Is it possible to do a dynamic
typedef and then use it afterwards ?

void createTypedef(std::string name){
typedef name;
}
no

The idea is to generate function pointers on the fly, i.e. during
runtime, so that I can call functions in plugins that I''m not aware of
at compile time, but they get delivered in a XML file accompagnying
the dll/so ?!
Any ideas are warmly appreciated!




您的操作系统提供的调用可以指向

在共享库中通过使用其名称的字符串来运行,你需要检查系统的文档(提示:

dlopen( )/ dlsym()on unix)


-

John Tsiombikas(核/实验室)
nu ***** @ siggraph.org
http://thelab.demoscene.gr/nuclear/


On Sun,2004年4月18日12:54:36 +0000(UTC),John Tsiombikas(Nuclear /

the Lab)" < NU ***** @ siggraph.org>写道:
On Sun, 18 Apr 2004 12:54:36 +0000 (UTC), "John Tsiombikas (Nuclear /
the Lab)" <nu*****@siggraph.org> wrote:
2004-04-18,Simon Moser< Si ********* @ gmx.de>写道:
On 2004-04-18, Simon Moser <Si*********@gmx.de> wrote:



我有一个有点愚蠢的问题:是否有可能做一个动态的
typedef,然后再使用它? br />
void createTypedef(std :: string name){
typedef name;
}

Hi,

I got a somewhat stupid question: Is it possible to do a dynamic
typedef and then use it afterwards ?

void createTypedef(std::string name){
typedef name;
}



no



no


想法是动态生成函数指针,即在运行时,这样我就可以在编译时调用我不知道的插件中的函数,但是它们是以XML文件的形式提供的,并伴随着dll / so?!
任何想法都受到了热烈的赞赏!

The idea is to generate function pointers on the fly, i.e. during
runtime, so that I can call functions in plugins that I''m not aware of
at compile time, but they get delivered in a XML file accompagnying
the dll/so ?!
Any ideas are warmly appreciated!



您的操作系统提供给您的电话通过使用带有名称的字符串指向共享库中的
函数,你应该检查系统的文档(提示:
dlopen()/ dlsym()在unix上)



Your operating system provides calls that give you pointers to the
functions in shared libraries by taking a string with its name, you
should check the documentation of your system for them (hint:
dlopen()/dlsym() on unix)




好​​的,我知道我可以使用

dlopen / dlsym或LoadLibrary / getProc获取我的lib中的entryPoint地址(在Windows上)。

问题是:在我得到entryPoint之后,我还需要调用这个

函数(并且可能传递参数)。那么我怎么能这样做呢?

只知道

运行时的函数名和输入+输出参数?



Ok, I know that I can get the entryPoint in my lib by using
dlopen/dlsym or LoadLibrary/getProcAdress (on Windows).
Problem is: After I got the entryPoint, I also need to call this
function (and probably pass parameters). So how could I do this if I
only know the function name and the input + output parameters at
runtime ?


On Sun,2004年4月18日15:21:02 +0200,Simon Moser< Si ********* @ gmx.de>

写道:
On Sun, 18 Apr 2004 15:21:02 +0200, Simon Moser <Si*********@gmx.de>
wrote:
On Sun,2004年4月18日12:54:36 +0000(UTC),John Tsiombikas(Nuclear /
the Lab) < NU ***** @ siggraph.org>写道:
On Sun, 18 Apr 2004 12:54:36 +0000 (UTC), "John Tsiombikas (Nuclear /
the Lab)" <nu*****@siggraph.org> wrote:
2004-04-18,Simon Moser< Si ********* @ gmx.de>写道:
On 2004-04-18, Simon Moser <Si*********@gmx.de> wrote:



我有一个有点愚蠢的问题:是否有可能做一个动态的
typedef,然后再使用它? br />
void createTypedef(std :: string name){
typedef name;
}

Hi,

I got a somewhat stupid question: Is it possible to do a dynamic
typedef and then use it afterwards ?

void createTypedef(std::string name){
typedef name;
}



no



no


想法是动态生成函数指针,即在运行时,这样我就可以在编译时调用我不知道的插件中的函数,但是它们是以XML文件的形式提供的,并伴随着dll / so?!
任何想法都受到了热烈的赞赏!

The idea is to generate function pointers on the fly, i.e. during
runtime, so that I can call functions in plugins that I''m not aware of
at compile time, but they get delivered in a XML file accompagnying
the dll/so ?!
Any ideas are warmly appreciated!



您的操作系统提供给您的电话通过使用带有名称的字符串指向共享库中的
函数,你应该检查系统的文档(提示:
dlopen()/ dlsym()在unix上)



Your operating system provides calls that give you pointers to the
functions in shared libraries by taking a string with its name, you
should check the documentation of your system for them (hint:
dlopen()/dlsym() on unix)



好的,我知道我可以使用
dlopen / dlsym或LoadLibrary / getProcAdress(在Wi上)获取我的lib中的entryPoint ndows)。
问题是:在我得到entryPoint之后,我还需要调用这个
函数(并且可能传递参数)。那么如果我只知道运行时的函数名和输入+输出参数怎么办呢?



Ok, I know that I can get the entryPoint in my lib by using
dlopen/dlsym or LoadLibrary/getProcAdress (on Windows).
Problem is: After I got the entryPoint, I also need to call this
function (and probably pass parameters). So how could I do this if I
only know the function name and the input + output parameters at
runtime ?




这意味着我需要构造函数的签名才能实时调用,所以我的想法是构造一个具有

签名的字符串,然后转换它一个函数指针,我可以调用

(也许使用像dynamic_cast这样的东西?)但我似乎无法想象如何获得
。在此先感谢您的帮助



That means that I need to construct the signature of the function to
be called on-the-fly, So my idea is to construct a string that has the
signature, and then convert it to a function pointer that I can call
(maybe using something like dynamic_cast??) But I can''t seem to figure
out how. Thanks in advance for any help


这篇关于动态typedef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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