Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : expat callbacks and linkage.
New Topic New Poll Post Reply
Poster Message
coppro
Level: Smitemaster
Rank Points: 1309
Registered: 11-24-2005
IP: Logged
icon expat callbacks and linkage. (+1)  
The expat callbacks used by CDbXML are static class members, but since expat is a C interface, it is nonportable to use anything but an extern "C" global function for the callbacks. I would recommend inserting just before each callback function something like:

extern "C" DbXMLCTallyElementCForward (void * ud, const char * name, const char ** atts) { CDbXml::TallyElement(ud, name, atts); }

void CDbXml::TallyElement(
...

01-07-2008 at 11:16 AM
View Profile Show all user's posts Quote Reply
schep
Level: Smitemaster
Avatar
Rank Points: 865
Registered: 03-01-2005
IP: Logged
icon Re: expat callbacks and linkage. (0)  
This is technically true, but I'm curious: was there somewhere this actually came up? I've never seen a compiler that treated function pointers with and without 'extern "C"' differently.

01-08-2008 at 04:57 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
coppro
Level: Smitemaster
Rank Points: 1309
Registered: 11-24-2005
IP: Logged
icon Re: expat callbacks and linkage. (0)  
I noticed it, basically. I was thinking about ways to circumvent member pointers when using C libraries, but I realized that it's completely impossible due to the technical requirement of extern "C".

EDIT: Without macros, of course, but those are evil, as we all know.

[Last edited by coppro at 01-08-2008 05:09 AM]
01-08-2008 at 05:08 AM
View Profile Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5106
Registered: 02-04-2003
IP: Logged
icon Re: expat callbacks and linkage. (0)  
coppro wrote:
The expat callbacks used by CDbXML are static class members, but since expat is a C interface, it is nonportable to use anything but an extern "C" global function for the callbacks. I would recommend inserting just before each callback function something like:

extern "C" DbXMLCTallyElementCForward (void * ud, const char * name, const char ** atts) { CDbXml::TallyElement(ud, name, atts); }

void CDbXml::TallyElement(
...
Sure, I don't mind adding this structure, though it will generate more function calls and slow down your import procedure by a millisecond. O:-

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
01-24-2008 at 05:55 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : expat callbacks and linkage.
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.