[Snowball-discuss] call stemmer from C++

Jacob Hallenborg cl9jhall@cling.gu.se
Tue Mar 25 17:05:01 2003


Thanks for your quick reply!

Unfortunately I'm not a so good at this. Should I put the extern stuff 
in api.h, header.h and stem.h? And should the braces include the whole 
file (all declarations) or just some part? I guess the 
include-statements in the C++ code doesn't need any extern stuff?
I'm using gcc 2.95.

Thanks,
/jacob



Olly Betts wrote:

>On Tue, Mar 25, 2003 at 05:16:40PM +0100, Jacob Hallenborg wrote:
>  
>
>>Does anyone know how to call the generated C stemmer from a C++ program. 
>>I've been trying to insert 'extern "C"' at various places in the 
>>driver-porter.c-example, but with no success.
>>    
>>
>
>We call them from the Xapian C++ library by adding 'extern "C"' wrappers
>to the *header* files like so:
>
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
>  
>  /* This file was generated automatically by the Snowball to ANSI C
>   * compiler */
>  
>  extern struct SN_env * snowball_english_create_env(void);
>  extern void snowball_english_close_env(struct SN_env * z);
>  
>  extern int snowball_english_stem(struct SN_env * z);
>  
>  #ifdef __cplusplus
>  }
>  #endif
>
>Then just include this from your C++ source and call the functions as
>you would from C.  It would be good if the snowball compiler added this
>wrapper.  Martin: the changes should be obvious, but let me know if you
>want a patch.
>
>Cheers,
>    Olly
>
>  
>