From cd671dbc3da0d2e95d44d2d62c693d5aff08aae3 Mon Sep 17 00:00:00 2001 From: Ilya Lipnitskiy Date: Wed, 13 May 2020 15:10:33 -0700 Subject: [PATCH] protobuf-c.c, protoc-c: Remove leading underscores Fixes #188. Implements suggested fix from the issue: The struct tag namespace is different from the type namespace. Use the same symbol names (i.e. without leading underscores) in every namespace. --- protobuf-c/protobuf-c.c | 4 ++-- protoc-c/c_message.cc | 4 ++-- protoc-c/c_service.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c index 8976e36..aea2e1b 100644 --- a/protobuf-c/protobuf-c.c +++ b/protobuf-c/protobuf-c.c @@ -2095,9 +2095,9 @@ parse_tag_and_wiretype(size_t len, /* sizeof(ScannedMember) must be <= (1UL<Print("typedef struct _$classname$ $classname$;\n", + printer->Print("typedef struct $classname$ $classname$;\n", "classname", FullNameToC(descriptor_->full_name())); for (int i = 0; i < descriptor_->nested_type_count(); i++) { @@ -179,7 +179,7 @@ GenerateStructDefinition(io::Printer* printer) { PrintComment (printer, msgSourceLoc.leading_comments); printer->Print(vars, - "struct $dllexport$ _$classname$\n" + "struct $dllexport$ $classname$\n" "{\n" " ProtobufCMessage base;\n"); diff --git a/protoc-c/c_service.cc b/protoc-c/c_service.cc index ad09ff1..a4ae1d7 100644 --- a/protoc-c/c_service.cc +++ b/protoc-c/c_service.cc @@ -98,8 +98,8 @@ void ServiceGenerator::GenerateMainHFile(io::Printer* printer) void ServiceGenerator::GenerateVfuncs(io::Printer* printer) { printer->Print(vars_, - "typedef struct _$cname$_Service $cname$_Service;\n" - "struct _$cname$_Service\n" + "typedef struct $cname$_Service $cname$_Service;\n" + "struct $cname$_Service\n" "{\n" " ProtobufCService base;\n"); for (int i = 0; i < descriptor_->method_count(); i++) {