From: Felipe Contreras Date: Thu, 11 May 2023 18:39:05 GMT Subject: Re: [PATCH 23/24] hash-ll, hashmap: move oidhash() to hash-ll Message-ID: <645d3649c6c7a_2606922942e@chronos.notmuch> In-Reply-To: <20230511183143.GA1978320@coredump.intra.peff.net> Jeff King wrote: > khash.h lets you instantiate custom hash types that map between two > types. These are defined as a struct, as you might expect, and khash > typedef's that to kh_foo_t. But it declares the struct anonymously, > which doesn't give a name to the struct type itself; there is no > "struct kh_foo". This has two small downsides: > > - when using khash, we declare "kh_foo_t *the_foo". This is > unlike our usual naming style, which is "struct kh_foo *the_foo". > > - you can't forward-declare a typedef of an unnamed struct type in > C. So we might do something like this in a header file: > > struct kh_foo; > struct bar { > struct kh_foo *the_foo; > }; > > to avoid having to include the header that defines the real > kh_foo. But that doesn't work with the typedef'd name. Without the > "struct" keyword, the compiler doesn't know we mean that kh_foo is > a type. One of the reasons why Linux doesn't do typedef. -- Felipe Contreras