Skip to main content
gamedev.net
🔒 Locked

managed C++ problem

Started by guyaton Oct 18, 2005 at 11:31 AM 2 replies 500+ views
Original Post
guyaton
guyaton
Trying to create a managed wrapper for C# this extractor:libextractor http://gnunet.org/libextractor/ It is for a friend and he needs it this way.

typedef __gc struct EXTRACTOR_Keywords 
{  
/* the keyword that was found */  
char * keyword;  
/* the type of the keyword (classification) */  
EXTRACTOR_KeywordType keywordType;  
/* the next entry in the list */  
__gc struct EXTRACTOR_Keywords * next;
} EXTRACTOR_KeywordList;


typedef EXTRACTOR_KeywordList *(*ExtractMethod)( 
const char * filename,		 
char * data,		
 size_t filesize,		 
EXTRACTOR_KeywordList * next,		 
const char * options);

typedef __gc struct EXTRACTOR_Extractor 
{  
void * libraryHandle;  
char * libname;  
ExtractMethod extractMethod;  
__gc struct EXTRACTOR_Extractor * next; 
 char * options;
} EXTRACTOR_ExtractorList;


and this is the error: EXTRACTOR_Keywords': a __gc type object cannot be passed by value It is pointing to: ExtractMethod extractMethod; in struct EXTRACTOR_Extractor. If I remove this line it compiles, but of course it doesn't work properly. Any ideas? thanks in advance, ~guyaton
~guyaton
matthughson
matthughson
First I should say I don't think I've done anything this complex in C#, and have no idea what that __gc stuff is, but this line seems wrong to me:
/* the next entry in the list */  __gc struct EXTRACTOR_Keywords * next;

Does/Should that 'struct' key word me there (and the __gc for that matter)?
/* the next entry in the list */  __gc EXTRACTOR_Keywords * next;

Again, I'm not familiar with the __gc thing, or type defing struct and redifining them at the same time, so maybe it should be.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
guyaton
guyaton
this code snippet is Managed C++ that I am trying to create a wrapper for some C code so that it can be used with C#.


~guyaton
~guyaton
rmsimpson
rmsimpson
First, shouldn't the code be:

typedef __gc struct EXTRACTOR_Extractor {  void * libraryHandle;  char * libname;  ExtractMethod *extractMethod;  __gc struct EXTRACTOR_Extractor * next;  char * options;} EXTRACTOR_ExtractorList;


Specifically, instead of:
ExtractMethod extractMethod;

It's:
ExtractMethod *extractMethod;

Second ... I would recommend writing your wrapper a little differently. Create an API that doesn't require these linked lists, which is inherently problematic in .NET.

Robert

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.