[gtk-doc] scangobj: Avoid generating unused params
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] scangobj: Avoid generating unused params
- Date: Wed, 1 Nov 2017 20:08:29 +0000 (UTC)
commit e39e5f87cb9157a6991ae72c7a7ea014f6df7a02
Author: Pavel Grunt <pavelgrunt gmail com>
Date: Sun Oct 29 10:07:23 2017 +0100
scangobj: Avoid generating unused params
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 files changed, 9 insertions(+), 1 deletions(-)
---
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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]