From aa1f31d4013163176a8404a003b472ab79ac177d Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 19 May 2017 09:44:09 +0200 Subject: [PATCH] Silence empty struct warning Last but not least, -Wpedantic warns about empty structs. With this, -Wpedantic build is now clean of warnings on gcc 5.4.0 and clang 4.0. --- compiler/capnpc-c.c | 4 +++- compiler/test.capnp.h | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index 166aea6..6b976c6 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -960,7 +960,9 @@ static void define_struct(struct node *n) { str_add(&HDR, s.enums.str, s.enums.len); - str_addf(&HDR, "\nstruct %s {\n", n->name.str); + str_addf(&HDR, "\n%sstruct %s {\n", + s.decl.len == 0 ? "capnp_nowarn " : "", + n->name.str); str_add(&HDR, s.decl.str, s.decl.len); str_addf(&HDR, "};\n"); diff --git a/compiler/test.capnp.h b/compiler/test.capnp.h index 949913f..5a0b26b 100644 --- a/compiler/test.capnp.h +++ b/compiler/test.capnp.h @@ -1096,7 +1096,7 @@ void TestLists_set_textListList(TestLists_ptr p, capn_ptr textListList); void TestLists_set_structListList(TestLists_ptr p, capn_ptr structListList); -struct TestLists_Struct0 { +capnp_nowarn struct TestLists_Struct0 { }; static const size_t TestLists_Struct0_word_count = 0; @@ -1553,7 +1553,7 @@ void TestWholeFloatDefault_set_field(TestWholeFloatDefault_ptr p, float field); void TestWholeFloatDefault_set_bigField(TestWholeFloatDefault_ptr p, float bigField); -struct TestEmptyStruct { +capnp_nowarn struct TestEmptyStruct { }; static const size_t TestEmptyStruct_word_count = 0; @@ -1562,7 +1562,7 @@ static const size_t TestEmptyStruct_pointer_count = 0; static const size_t TestEmptyStruct_struct_bytes_count = 0; -struct TestConstants { +capnp_nowarn struct TestConstants { }; static const size_t TestConstants_word_count = 0; @@ -1618,7 +1618,7 @@ enum TestSturdyRefObjectId_Tag TestSturdyRefObjectId_get_tag(TestSturdyRefObject void TestSturdyRefObjectId_set_tag(TestSturdyRefObjectId_ptr p, enum TestSturdyRefObjectId_Tag tag); -struct TestProvisionId { +capnp_nowarn struct TestProvisionId { }; static const size_t TestProvisionId_word_count = 0; @@ -1627,7 +1627,7 @@ static const size_t TestProvisionId_pointer_count = 0; static const size_t TestProvisionId_struct_bytes_count = 0; -struct TestRecipientId { +capnp_nowarn struct TestRecipientId { }; static const size_t TestRecipientId_word_count = 0; @@ -1636,7 +1636,7 @@ static const size_t TestRecipientId_pointer_count = 0; static const size_t TestRecipientId_struct_bytes_count = 0; -struct TestThirdPartyCapId { +capnp_nowarn struct TestThirdPartyCapId { }; static const size_t TestThirdPartyCapId_word_count = 0; @@ -1645,7 +1645,7 @@ static const size_t TestThirdPartyCapId_pointer_count = 0; static const size_t TestThirdPartyCapId_struct_bytes_count = 0; -struct TestJoinResult { +capnp_nowarn struct TestJoinResult { }; static const size_t TestJoinResult_word_count = 0;