From e39e5f87cb9157a6991ae72c7a7ea014f6df7a02 Mon Sep 17 00:00:00 2001 From: Pavel Grunt Date: Sun, 29 Oct 2017 10:07:23 +0100 Subject: [PATCH] scangobj: Avoid generating unused params MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The main function params may be unused depending on type init function definition. That may lead to generating a warning about unused in a project using gtk-doc, eg: DOC Scanning header files DOC Introspecting gobjects spice-gtk-scan.c: In function ‘main’: spice-gtk-scan.c:126:11: warning: unused parameter ‘argc’ [-Wunused-parameter] main (int argc, char *argv[]) ^~~~ spice-gtk-scan.c:126:23: warning: unused parameter ‘argv’ [-Wunused-parameter] main (int argc, char *argv[]) Check for the presence of argc and argv in the type init function and generate main function params accordingly https://bugzilla.gnome.org/show_bug.cgi?id=773879 --- gtkdoc/scangobj.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gtkdoc/scangobj.py b/gtkdoc/scangobj.py index 116270a..235a851 100644 --- a/gtkdoc/scangobj.py +++ b/gtkdoc/scangobj.py @@ -125,7 +125,7 @@ static void output_args (void); static void output_object_args (FILE *fp, GType object_type); int -main (int argc, char *argv[]) +main (${main_func_params}) { ${type_init_func}; @@ -1229,6 +1229,14 @@ def run(options): # substitute local vars in the template type_init_func = options.type_init_func + main_func_params = "int argc, char *argv[]" + if "argc" in type_init_func and "argv" not in type_init_func: + main_func_params = "int argc, G_GNUC_UNUSED char *argv[]" + elif "argc" not in type_init_func and "argv" in type_init_func: + main_func_params = "G_GNUC_UNUSED int argc, char *argv[]" + elif "argc" not in type_init_func and "argv" not in type_init_func: + main_func_params = "void" + output.write(string.Template(MAIN_CODE).substitute(locals())) if options.query_child_properties: -- 2.11.4.GIT