Re: [PATCH v5 12/15] strmap: enable allocations to come from a mem_pool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 11, 2020 at 11:02 AM Jeff King <peff@xxxxxxxx> wrote:
> Even if we're only using a pointer to it, we still need a valid forward
> declaration [in a function, but not in a struct definition] ...
> I'm not sure whether this is a seldom-seen corner of the C standard, or
> a compiler-specific thing (though both clang and gcc seem to allow it).

It is standard (and not all *that* seldom-seen, in that many compilers
have warnings when you put these in function prototype scope).  The
forward declaration is implicit, and occurs *in the current scope*.  The
trick is figuring out what the scope is.  At file level, the scope is "level
zero" as it were: file scope.  So it's as global as we get (C separates
"globality" into scope and linkage; *variables* have linkagebut *type
names* do not).  Function prototypes, however, have function-prototype
scope, which ends at the end of the function declaration.

Overall, though, I agree that the nicest style is to have an explicit
forward declaration (in C that is—note that in C++, struct is just a
class with everything public, and class definitions have scope!).

Chris




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux