Author Topic: gperf  (Read 203 times)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4753
  • I like bugs.
gperf
« on: September 19, 2026, 02:48:49 pm »
FYI
I wanted to experiment with perfect hash functions and tables because it was mentioned in this video.
https://www.youtube.com/watch?v=DMQ_HcNSOAI

This is my input file keywords.gperf.

Code: [Select]
struct month { char *name }
%%
january
february
march
april
may
june
july
august
september
november
december

Then a command "gperf keywords.gperf > perfhash.c"
gave me (among other useless C-code) a hash function that returns 0.

Code: C  [Select][+][-]
  1. static unsigned int
  2. hash (register const char *str, register size_t len)
  3. {
  4.   (void) str;
  5.   (void) len;
  6.   return 0;
  7. }
  8.  
Some people get proper hash functions so something is wrong in my input. I didn't find any simple example tutorial.
Anyway, always something happens with C-code...
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

jamie

  • Hero Member
  • *****
  • Posts: 8029
Re: gperf
« Reply #1 on: September 20, 2026, 02:28:31 pm »
I find C examples all over the place, there is something particular about what you are looking for?
https://github.com/Genbox/gperf-archive

Something to look at, I guess.

Jamie
« Last Edit: September 20, 2026, 02:48:09 pm by jamie »
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018