git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv4 6/6] Remove forward declaration of an enum

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 15, 2018, 20:40 UTC
Message-ID
<20180815204030.GC181377@aiede.svl.corp.google.com>
In-Reply-To
<20180815175410.5726-7-newren@gmail.com>
Elijah Newren wrote:
Show 8 quoted lines
> According to http://c-faq.com/null/machexamp.html, sizeof(char*) !=
> sizeof(int*) on some platforms.  Since an enum could be a char or int
> (or long or...), knowing the size of the enum thus is important to
> knowing the size of a pointer to an enum, so we cannot just forward
> declare an enum the way we can a struct.  (Also, modern C++ compilers
> apparently define forward declarations of an enum to either be useless
> because the enum was defined, or require an explicit size specifier, or
> be a compilation error.)

Beyond the effect on some obscure platforms, this also makes it possible to build with gcc -pedantic (which can be useful for finding some other problems). Thanks for fixing it.

[...]
Show 12 quoted lines
> --- a/packfile.h
> +++ b/packfile.h
> @@ -1,12 +1,12 @@
>  #ifndef PACKFILE_H
>  #define PACKFILE_H
>  
> +#include "cache.h"
>  #include "oidset.h"
>  
>  /* in object-store.h */
>  struct packed_git;
>  struct object_info;

Not about this patch: comments like the above are likely to go stale, since nothing verifies they continue to be true. So we should remove them. #leftoverbits

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Previous: Elijah NewrenNext: Elijah Newren
Message 3 of 14 in “[PATCHv4 0/6] Add missing includes and forward declares”
  1. Elijah NewrenAug 15, 2018
  2. 6/6 Remove forward declaration of an enumElijah Newren, Aug 15, 2018
  3. Jonathan NiederAug 15, 2018
  4. 4/6 urlmatch.h: fix include guardElijah Newren, Aug 15, 2018
  5. 2/6 alloc: make allocate_alloc_state and clear_alloc_state more consistentElijah Newren, Aug 15, 2018
  6. Jonathan NiederAug 15, 2018
  7. 5/6 compat/precompose_utf8.h: use more common include guard styleElijah Newren, Aug 15, 2018
  8. 3/6 Move definition of enum branch_track from cache.h to branch.hElijah Newren, Aug 15, 2018
  9. 1/6 Add missing includes and forward declarationsElijah Newren, Aug 15, 2018
  10. Jonathan NiederAug 15, 2018
  11. Jonathan NiederAug 15, 2018
  12. Ramsay JonesAug 16, 2018
  13. Junio C HamanoAug 16, 2018
  14. Jeff KingAug 16, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.