[libvoikko] Namespace collisions in HFST and Lttoolbox

Flammie Pirinen flammie at iki.fi
Wed Mar 17 07:47:49 EET 2010

2010-03-12, Harri Pitkänen sanoi:

> First there is a problem specific to HFST only: When configured using
> pkg- config, -I/include/hfst2 is added to CFLAGS. This breaks things
> because this directory contains file "string.h" which now gets
> included in place of the standard C header with the same name. I
> suppose that the HFST file should be included as <hfst2/string.h> and
> adding the directory to include path is unnecessary. The small patch
> at the end of this message fixes the problem.

Fixed earlier this week, as suggested in patch.

> Another problem is that both HFST and Lttoolbox introduce some
> classes in the default namespace. Since the libraries serve similar
> purposes it is not a surprise that some of the classes have exactly
> same names. Here are some examples, there might be others too:

Hfst 3 was designed to avoid pollution of default namespace, so moving
to it will at least solve problem.

> /usr/include/lttoolbox-3.1/lttoolbox/alphabet.h:35: error:
> redefinition of ‘class Alphabet’
> /home/harri/apps/include/hfst2/sfst/alphabet.h:220: error: previous
> definition of ‘class Alphabet’
> /usr/include/lttoolbox-3.1/lttoolbox/node.h:107: error: redefinition
> of ‘class Node’
> /home/harri/apps/include/hfst2/sfst/fst.h:375: error: previous
> definition of ‘class Node’

These do leak from SFST engine, so I assume fix for current hfst would
be non-trivial.

> /usr/include/lttoolbox-3.1/lttoolbox/state.h:36: error: redefinition
> of ‘union State’
> /home/harri/apps/include/hfst2/hfst.h:12: error: previous definition
> of ‘union State’

I think State should not be in default namespace here.

Flammie, computer scientist bachelor, linguist master, free software
Finnish localiser, and more! <http://www.iki.fi/flammie/>

More information about the Libvoikko mailing list