Objectmix
Tags Register Mark Forums Read

How to devise function pointer type from function name? : c++

This is a discussion on How to devise function pointer type from function name? within the c++ forums in Programming Languages category; Hi All, Can I devise function pointer type from function name by using template programming? e.g. I have function: exertn “C” void xmlFreeDoc(xmlDocPtr cur); I want something like following: typeof(xmlFreeDoc) functionpointer = xmlFreeDoc; i.e value to type conversion I want pass this type to Holder which will call this function in dtor. Currently I am using following code to do the same task: extern "C" { typedef void (*funcPtr)(void*) ; } Holder<xmlChar, funcPtr, false> val(xmlNodeListGetString(doc, cur_node- >children, 1), xmlFree); Issues with above code: I need to add every type of function in the extern “C” block. Thanks, Nitin. -- [ ...


Object Mix > Programming Languages > c++ > How to devise function pointer type from function name?

c++ comp.lang.c++ usenet archive

Reply

 

LinkBack Thread Tools
  #1  
Old 09-12-2008, 05:11 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default How to devise function pointer type from function name?

Hi All,

Can I devise function pointer type from function name by using
template programming?
e.g.
I have function:
exertn “C” void xmlFreeDoc(xmlDocPtr cur);
I want something like following:
typeof(xmlFreeDoc) functionpointer = xmlFreeDoc;
i.e value to type conversion
I want pass this type to Holder which will call this function in dtor.

Currently I am using following code to do the same task:
extern "C" {
typedef void (*funcPtr)(void*) ;
}
Holder<xmlChar, funcPtr, false> val(xmlNodeListGetString(doc, cur_node-
>children, 1), xmlFree);


Issues with above code:
I need to add every type of function in the extern “C” block.

Thanks,
Nitin.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Reply

Thread Tools



All times are GMT -5. The time now is 01:01 AM.

Managed by Infnx Pvt Ltd.