Next: , Previous: Contributors, Up: Top

1 Introduction

gperf is a perfect hash function generator written in C++. It transforms an n element user-specified keyword set W into a perfect hash function F. F uniquely maps keywords in W onto the range 0..k, where k >= n-1. If k = n-1 then F is a minimal perfect hash function. gperf generates a 0..k element static lookup table and a pair of C functions. These functions determine whether a given character string s occurs in W, using at most one probe into the lookup table.

gperf currently generates the reserved keyword recognizer for lexical analyzers in several production and research compilers and language processing tools, including GNU C, GNU C++, GNU Java, GNU Pascal, GNU Modula 3, and GNU indent. Complete C++ source code for gperf is available from A paper describing gperf's design and implementation in greater detail is available in the Second USENIX C++ Conference proceedings or from