mapi: Silence many "warning: unused parameter"
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 26 Aug 2011 00:27:08 +0000 (17:27 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 27 Aug 2011 06:33:12 +0000 (23:33 -0700)
When generating dispatch templates, emit the '(void) blah;' magic to
make GCC happy.  This reduces a lot of warning spam if you build with
-Wunused-parameter or -Wextra.

Reviewed-by: Chia-I Wu <olv@lunarg.com>
src/mapi/glapi/gen/gl_apitemp.py
src/mapi/mapi/mapi_abi.py

index 41a40fbeb681d28c33a7de5b948ae0671fc263ca..72c2e46c37ec11a2f63ab2ee24b7ab3712129550 100644 (file)
@@ -64,6 +64,8 @@ class PrintGlOffsets(gl_XML.gl_print_base):
 
                n = f.static_name(name)
 
+               silence = ''
+               space = ''
                for p in f.parameterIterator():
                        if p.is_padding:
                                continue
@@ -78,6 +80,9 @@ class PrintGlOffsets(gl_XML.gl_print_base):
                        o_string = o_string + comma + cast + p.name
                        comma = ", "
 
+                       silence += "%s(void) %s;" % (space, p.name);
+                       space = ' '
+
 
                if f.return_type != 'void':
                        dispatch = "RETURN_DISPATCH"
@@ -97,6 +102,8 @@ class PrintGlOffsets(gl_XML.gl_print_base):
 
                print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))
                print '{'
+               if silence:
+                       print '    %s' % (silence)
                if p_string == "":
                        print '   %s(%s, (), (F, "gl%s();\\n"));' \
                                % (dispatch, f.name, name)
index e3d3f6518ec43acf3da2661b9482cffd9fc9ecb0..c18dd82d6e5b19f74d5bd1d42eeaf6dacb162581 100644 (file)
@@ -503,7 +503,16 @@ class ABIPrinter(object):
 
             proto = self._c_decl(ent, prefix, False, 'static')
 
-            stmt1 = self.indent + '%s(%s);' % (self.noop_warn,
+            stmt1 = self.indent;
+            space = ''
+            for t, n, a in ent.params:
+                stmt1 += "%s(void) %s;" % (space, n)
+                space = ' '
+
+            if ent.params:
+                stmt1 += '\n';
+
+            stmt1 += self.indent + '%s(%s);' % (self.noop_warn,
                     self._c_function(ent, warn_prefix, False, True))
 
             if ent.ret: