[XForms] Towards a warning-free compilation.

Angus Leeming angus.leeming at btopenworld.com
Wed Nov 19 18:06:17 EST 2003


I have been trying to reduce the number of warnings when compiling xforms with
CFLAGS='-O2 -W -Wall -Wno-unused-parameter -pedantic'
That's about as strict as C will allow.

There are currently two main groups of warning messages: 'uninitialized 
variable' (almost all in the declaration of arrays) and 'comparison between 
signed and unsigned'.

Attached is a tentative patch that removes all of the 'uninitialized variable' 
warnings. I say tentative because xforms tends to use macros such as
#define NV(a) (#a,a)
to simplify such initializations. Eg:

#define NV(a)    #a,a
static FL_IMAP fl_imap[FL_MAX_COLS] =
{
	{NV(FL_BLACK), 0, 0, 0, 0, 0},
	{NV(FL_WHITE), 255, 255, 255, 0, 0},

I have squashed the warnings in the case above by adding the final ', 0, 0' to 
the decalrations, but I could arguably achieve the same end by extending the 
definition of the NV macro to:

#define NV(a,r,g,b) ({#a,a,r,g,b,0,0})

static FL_IMAP fl_imap[FL_MAX_COLS] =
{
	NV(FL_BLACK, 0, 0, 0),
	NV(FL_WHITE, 255, 255, 255),

Given that NV exists already, would it not be more elegant to do things the 
second way?

I also attach the log of the remaining_warnings and a little sed script that I 
used to strip most everything but the warnings out from the make log file.
$ make > make.log 2>&1
$ sed -f striplog.sed make.log > remaining_warnings.txt

You'll see that there are also a couple of warnings about inconsistent 
declarations in there too...

Regards,
Angus
-------------- next part --------------
/^depfile/d
/^depmode/d
/^gcc/d
/^source/d
/^\/bin\/sh/d
/^make\[[123]\]/d
/^Making all/d
/^cp -p/d
/^creating/d
/^(cd/d
/^rm -f/d
/^mv -f/d
/^ar cru/d
/^mkdir/d
/^echo timestamp/d
/^config.status/d
/^cd/d
/^make/d
-------------- next part --------------
A non-text attachment was scrubbed...
Name: remaining_warnings.txt.gz
Type: application/x-gzip
Size: 1152 bytes
Desc: not available
Url : attachments/20031119/769cd83b/attachment-0020.gz 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: initialization.diff.gz
Type: application/x-gzip
Size: 5314 bytes
Desc: not available
Url : attachments/20031119/769cd83b/attachment-0021.gz 


More information about the Xforms mailing list