This topic is now archived and is closed to further replies.

A specific Question dealing with Classes in .dlls with the articles.

This topic is 5131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I don''t understand some things in C++, such as function pointers. I''ve been researching the .dll class thing for a few days, and I understand almost everything, except for a line or two.
extern "C"
	HRESULT createRendererInterface(rendererInterface **pInterface);
	typedef HRESULT (*CREATERENDERERINTERFACE)(rendererInterface **pInterface);

	HRESULT destroyRendererInterface(rendererInterface **pInterface);
	typedef HRESULT (*DESTROYRENDERERINTERFACE)(rendererInterface **pInterface);
I don''t really understand the typedef thing, and how it is used in the examples in the article. Could anyone give me a quick explanation about how they would be used?

Share this post

Link to post
Share on other sites
the typedef is just defining a type that can point to actual functions.

For example this:

typedef int i32;

would create a type that when used would point to an integer (technically speaking)

but this

typedef int (*pfn)(void);

would create a type that pointed to a function so that if you had a function like:

int myfunction()

you could do something like

pfn avar = myfunction;

and then calling ''avar'' with ''('' and '')'' would actually call teh function it points to.

avar(); // same as calling myfunction();

The typedef that''s in your question is based around the same concept of function pointers, but its a little more complicated syntax. if you did


then avar would have to point to a function that returns an HRESULT and takes a pointer to a pointer to a renderInterface

avar = // some function with above signature

renderInterface* pInterface;

avar( &pInterface );

would call the function that avar points to. This is basically used to initialize the interface to the dll.

Try this, it might help you out a bit more. It''s a plugin manager implementation.

:::: [ Triple Buffer ] ::::

Share this post

Link to post
Share on other sites