From 100b83a7faf277e2ea5ed2ec6f667ef5ac916416 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 25 Aug 2017 09:43:27 +0100 Subject: [PATCH] genmarshal Only wrap body prototypes in C++ guards Commit 31ae2c559810675aae483269f234a349cd933528 added the C++ guards around all prototypes, including inside the header file. The header file, though, already has C++ guards, so while it's harmless to have them there, it's also unnecessary. We should only emit C++ guards around the prototypes we include in the generated source. --- gobject/glib-genmarshal.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gobject/glib-genmarshal.in b/gobject/glib-genmarshal.in index ed6de0ae8..09e84083f 100755 --- a/gobject/glib-genmarshal.in +++ b/gobject/glib-genmarshal.in @@ -556,7 +556,7 @@ def generate_prototype(retval, params, va_marshal=False): '''Generate a marshaller declaration with the given @visibility. If @va_marshal is True, the marshaller will use variadic arguments in place of a GValue array.''' - signature = ['G_BEGIN_DECLS'] + signature = [] if visibility == Visibility.INTERNAL: signature += ['G_GNUC_INTERNAL'] @@ -585,8 +585,6 @@ def generate_prototype(retval, params, signature += [indent('int n_params,', level=width, fill=' ')] signature += [indent('GType *param_types);', level=width, fill=' ')] - signature += ['G_END_DECLS'] - return signature @@ -822,7 +820,11 @@ def generate_marshallers_body(outfile, retval, params, else: decl_visibility = Visibility.EXTERN proto = ['/* Prototype for -Wmissing-prototypes */'] + # Add C++ guards in case somebody compiles the generated code + # with a C++ compiler + proto += ['G_BEGIN_DECLS'] proto += generate_prototype(retval, params, prefix, decl_visibility, False) + proto += ['G_END_DECLS'] outfile.write('\n'.join(proto)) outfile.write('\n') @@ -838,7 +840,10 @@ def generate_marshallers_body(outfile, retval, params, else: decl_visibility = Visibility.EXTERN proto = ['/* Prototype for -Wmissing-prototypes */'] + # Add C++ guards here as well + proto += ['G_BEGIN_DECLS'] proto += generate_prototype(retval, params, prefix, decl_visibility, True) + proto += ['G_END_DECLS'] outfile.write('\n'.join(proto)) outfile.write('\n')