More g-wrap bogosities

Derek Atkins warlord@MIT.EDU
13 Jan 2002 12:26:02 -0500


Rob Browning <rlb@defaultvalue.org> writes:

> Derek Atkins <warlord@MIT.EDU> writes:
> 
> > g-wrap also produces code that produces these errors:
> >
> > gw-kvp.c: In function `gw_init_wrapset_gw_kvp':
> > gw-kvp.c:353: warning: unused variable `gw__tmp481_err_misc_msg'
> > gw-kvp.c:352: warning: unused variable `gw__tmp482_err_data'
> > gw-kvp.c:351: warning: unused variable `gw__tmp480_status_var'
> >
> > You do realize that a simple "(void)<varname>;" will cause these
> > warnings to go away, right?
> 
> Believe me, if there were an easy way to get rid of these I would.
> I'm actually the one that worked to make sure that gnucash compiled
> -Werror clean and then made it the default.
> 
> The problem is that there are good reasons why g-wrap is structured
> the way it is, but given that structure, I couldn't think of any way
> for it to tell in advance whether or not some of these variables are
> going to be used by later code that may or may not be generated by the
> scm->c and c->scm code generators for the various types being wrapped
> as arguments or return values for a given function (wow that was a
> mouthful...).

Why can't you just always add "(void)<varname>;" for every
variable/argument and always initialize stuff?  Don't worry about
whether the argument is used or not; just add a line for all of them.
As you say, g-wrap is already designed for the compiler to optimize
away unused code, and any decent optimizer will certainly work around
this construct....

> So the best I could do without a lot of extra infrastructure just for
> this purpose, is to recommend that people use -Wno-uninitialized
> -Wno-unused for the code generated by g-wrap.  That should be the
> default...

Is it a lot of extra infrastructure to keep a list of all the
variables and just output a set of 'compiler warning fixes' for them?

> Finally, I gave up on trying to format the wrapper code -- that just
> makes the g-wrap internals too complicated for very little gain, and
> "indent -nut -bli0 foo.c" works great, so if you want to look at the
> generated code, make sure to use indent first :>

Eh, lack of indentation in generated files doesn't bother me.

> Hope this helps.

I still might take a look at g-wrap and see if I can supply a fix to
output what I think will fix the warnings.

> -- 
> Rob Browning
> rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
> Previously @cs.utexas.edu
> GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available