diff --git a/usr.bin/getconf/fake-gperf.awk b/usr.bin/getconf/fake-gperf.awk
index 96fcd3c9977c..d56ec0141453 100644
--- a/usr.bin/getconf/fake-gperf.awk
+++ b/usr.bin/getconf/fake-gperf.awk
@@ -36,7 +36,8 @@ state == 1 { print; next; }
   state = 3;
   print "\t{ NULL, 0, 0 }";
   print "};";
-  print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
+  print "#include <sys/param.h>";
+  print "#define\tNWORDS\t(nitems(wordlist) - 1)";
   print "static const struct map *";
   print "in_word_set(const char *word)";
   print "{";