git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 0/1] Pedantic fix for Apple clang
@ 2018-07-25 21:56 Beat Bolli
  2018-07-25 21:56 ` [PATCH v2] packfile: ensure that enum object_type is defined Beat Bolli
  0 siblings, 1 reply; 3+ messages in thread
From: Beat Bolli @ 2018-07-25 21:56 UTC (permalink / raw)
  To: git; +Cc: gitster, Beat Bolli

Following up on my previous series bb/pedantic for gcc, this is a fix
for pedantic compilation under MacOS 10.13.6 (High Sierra) with the
command line tools of Xcode Version 9.4.1 (9F2000).

Changes against v1:

- [1/2]: include cache.h in packfile.h.

- [2/2]: drop it. Christian Couder is going to include this in the next
  version of the cc/remote-odb topic.

Beat Bolli (1):
  packfile: drop a repeated enum declaration

 packfile.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] packfile: ensure that enum object_type is defined
  2018-07-25 21:56 [PATCH v2 0/1] Pedantic fix for Apple clang Beat Bolli
@ 2018-07-25 21:56 ` Beat Bolli
  2018-07-26  0:44   ` Jonathan Nieder
  0 siblings, 1 reply; 3+ messages in thread
From: Beat Bolli @ 2018-07-25 21:56 UTC (permalink / raw)
  To: git; +Cc: gitster, Beat Bolli

When compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with
"make DEVELOPER=1 DEVOPTS=pedantic", the compiler says

    error: redeclaration of already-defined enum 'object_type' is a GNU
    extension [-Werror,-Wgnu-redeclared-enum]

According to https://en.cppreference.com/w/c/language/declarations
(section "Redeclaration"), a repeated declaration after the definition
is only legal for structs and unions, but not for enums.

Drop the belated declaration of enum object_type and include cache.h
instead to make sure the enum is defined.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 packfile.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packfile.h b/packfile.h
index 51383774ec72..28318c5c7c42 100644
--- 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;
-enum object_type;
 
 /*
  * Generate the filename to be used for a pack file with checksum "sha1" and
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] packfile: ensure that enum object_type is defined
  2018-07-25 21:56 ` [PATCH v2] packfile: ensure that enum object_type is defined Beat Bolli
@ 2018-07-26  0:44   ` Jonathan Nieder
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2018-07-26  0:44 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, gitster, Stefan Beller

Beat Bolli wrote:

> When compiling under Apple LLVM version 9.1.0 (clang-902.0.39.2) with
> "make DEVELOPER=1 DEVOPTS=pedantic", the compiler says
>
>     error: redeclaration of already-defined enum 'object_type' is a GNU
>     extension [-Werror,-Wgnu-redeclared-enum]
>
> According to https://en.cppreference.com/w/c/language/declarations
> (section "Redeclaration"), a repeated declaration after the definition
> is only legal for structs and unions, but not for enums.
>
> Drop the belated declaration of enum object_type and include cache.h
> instead to make sure the enum is defined.
>
> Helped-by: Jonathan Nieder <jrnieder@gmail.com>
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
>  packfile.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks!  I had run into this using clang on Linux, too, but hadn't
spent the time to track it down and write a patch.

Running

	git grep -e 'enum [^ ]*;'

doesn't find any other instances of this error.  Thanks for fixing it.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

By the way, not about this patch:

[...]
> +++ 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;
> -enum object_type;

This '/* in object-store.h */' comment can easily go stale since
nothing enforces that it stays accurate.  I don't think it's a useful
comment to have anyway, since it's straightforward to grep for where
the struct is defined.  I think we should remove the comment.

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-26  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 21:56 [PATCH v2 0/1] Pedantic fix for Apple clang Beat Bolli
2018-07-25 21:56 ` [PATCH v2] packfile: ensure that enum object_type is defined Beat Bolli
2018-07-26  0:44   ` Jonathan Nieder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).