You are not logged in

background: I use gperf for embedded development to maintain a key-value database in flash for a fixed set of variables. When I get a string from the outside world I use the 'lookup' function. A subset of the variables are never exposed to the outside world, counters, statistics and are manipulated internally. For these variables it would be very convenient to have a macro which would calculate the hash value of the known string (lookup("foo")): this would give me the index at compile time, which could be used to give (1) a compile time guarantee that I only try to look up existing strings and (2) would avoid the runtime overhead of calculating the hash for known strings.

(1) would be a pleasant property, (2) would be extremely useful to avoid the runtime overhead for a code base with hundreds of internal variables.

If there are no takers, I will probably end up doing this, in which case I'll be glad to submit a patch if there is interest.