www.delorie.com/gnu/docs/gperf/gperf_17.html   search  
 
Buy GNU books!


Perfect Hash Function Generator

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Options for fine tuning Details in the Output Code

`-K key-name'
`--slot-name=key-name'
This option is only useful when option `-t' has been given. By default, the program assumes the structure component identifier for the keyword is `name'. This option allows an arbitrary choice of identifier for this component, although it still must occur as the first field in your supplied struct.

`-F initializers'
`--initializer-suffix=initializers'
This option is only useful when option `-t' has been given. It permits to specify initializers for the structure members following key name in empty hash table entries. The list of initializers should start with a comma. By default, the emitted code will zero-initialize structure members following key name.

`-H hash-function-name'
`--hash-fn-name=hash-function-name'
Allows you to specify the name for the generated hash function. Default name is `hash'. This option permits the use of two hash tables in the same file.

`-N lookup-function-name'
`--lookup-fn-name=lookup-function-name'
Allows you to specify the name for the generated lookup function. Default name is `in_word_set'. This option permits completely automatic generation of perfect hash functions, especially when multiple generated hash functions are used in the same application.

`-Z class-name'
`--class-name=class-name'
This option is only useful when option `-L C++' has been given. It allows you to specify the name of generated C++ class. Default name is Perfect_Hash.

`-7'
`--seven-bit'
This option specifies that all strings that will be passed as arguments to the generated hash function and the generated lookup function will solely consist of 7-bit ASCII characters (characters in the range 0..127). (Note that the ANSI C functions isalnum and isgraph do not guarantee that a character is in this range. Only an explicit test like `c >= 'A' && c <= 'Z'' guarantees this.) This was the default in versions of gperf earlier than 2.7; now the default is to assume 8-bit characters.

`-c'
`--compare-strncmp'
Generates C code that uses the strncmp function to perform string comparisons. The default action is to use strcmp.

`-C'
`--readonly-tables'
Makes the contents of all generated lookup tables constant, i.e., "readonly". Many compilers can generate more efficient code for this by putting the tables in readonly memory.

`-E'
`--enum'
Define constant values using an enum local to the lookup function rather than with #defines. This also means that different lookup functions can reside in the same file. Thanks to James Clark <jjc@ai.mit.edu>.

`-I'
`--includes'
Include the necessary system include file, <string.h>, at the beginning of the code. By default, this is not done; the user must include this header file himself to allow compilation of the code.

`-G'
`--global'
Generate the static table of keywords as a static global variable, rather than hiding it inside of the lookup function (which is the default behavior).

`-W hash-table-array-name'
`--word-array-name=hash-table-array-name'
Allows you to specify the name for the generated array containing the hash table. Default name is `wordlist'. This option permits the use of two hash tables in the same file, even when the option `-G' is given.

`-S total-switch-statements'
`--switch=total-switch-statements'
Causes the generated C code to use a switch statement scheme, rather than an array lookup table. This can lead to a reduction in both time and space requirements for some keyfiles. The argument to this option determines how many switch statements are generated. A value of 1 generates 1 switch containing all the elements, a value of 2 generates 2 tables with 1/2 the elements in each switch, etc. This is useful since many C compilers cannot correctly generate code for large switch statements. This option was inspired in part by Keith Bostic's original C program.

`-T'
`--omit-struct-type'
Prevents the transfer of the type declaration to the output file. Use this option if the type is already defined elsewhere.

`-p'
This option is supported for compatibility with previous releases of gperf. It does not do anything.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003