[Snowball-discuss] call stemmer from C++

Olly Betts olly@survex.com
Tue Mar 25 16:42:01 2003


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