bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: including two gperf-generated .c files


From: Bruno Haible
Subject: Re: including two gperf-generated .c files
Date: Sun, 9 Sep 2007 04:21:54 +0200
User-agent: KMail/1.5.4

Hello Jim,

> recently I included two gperf-generated .c files into one

This is not supported. It is easy to work around this limitation, by using
different compilation units.

>     /* Un-define the following so that subsequent of the next gperf-generated
>        .c file doesn't evoke redefinition errors.  */
>     #undef TOTAL_KEYWORDS
>     #undef MIN_WORD_LENGTH
>     #undef MAX_WORD_LENGTH
>     #undef MIN_HASH_VALUE
>     #undef MAX_HASH_VALUE
> 
>     #include "col-lookup.c"
> 
> It would be nice if those #undef directives were
> emitted automatically into each .c file.

We can't do that, for backward compatibility: Some users of gperf use
these macros (e.g. GNU libiconv, see libiconv/lib/iconv.c).

Also, it would be unwise to #undef these macros at the top of the gperf-
generated file, because then there would be no warnings if the user happens
to have macros of the same name and the gperf-generated file redefines them.

> Also nice would be an option to specify a new name for the
> "hash" function.

Since having two gperf generated files in the same compilation unit is
unsupported, and since the "hash" function has 'static' visibility, this
is not needed.

> FYI, here are the options I'm using, followed by the commands
> used to generated the two files mentioned above:
> 
> GPERF_OPTIONS = \
>   --language=ANSI-C \
>   --readonly-tables \
>   --no-strlen \
>   --struct-type \
>   --size-multiple 2 \
>   --key-positions='*'

Note that since gperf-3.0, most of these options can be stored inside the
gperf input file itself. This simplifies the Makefiles. See node
'Declarations' in the gperf documentation.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]