Re: Compiler Warnings
- From: Miroslaw Dobrzanski-Neumann <mne mosaic-ag com>
- To: gtk-devel-list gnome org
- Subject: Re: Compiler Warnings
- Date: Mon, 18 Feb 2002 08:43:33 +0100
On Sat, Feb 16, 2002 at 07:01:49PM -0500, David L. Cooper II wrote:
> I generally compile glib/gtk+ on Solaris using Sun's compiler. I also have
> gcc loaded and use it on occasion. I've noticed that the sun compiler
> generates warnings in areas that gcc does not. Is anyone other than me
> interested in resolving these? If not, I won't bother. The code does compile
> but all the warnings make me nervous. Maybe it's just a personal problem ;>
>
> If there IS interest, I'll start working on resolving some of these.
Generally I would turn on all warnings and the stop on warning option for each
compiler used. In many cases a warning reported by the compiler is indeed an
error.
for gcc one get many extra warnings with -W option and -Werror stops the
compilation at first warning
for xlc setting -qhalt=W behaves like gcc's -Werror
And other question
Why is the type gsize not just size_t?
Here the current procedure taken from configure
on AIX size_t is a unsigned long (a typedef in system header)
sizeof(size_t) evaluates to 4
glib_size_t=$glib_cv_sizeof_size_t
case x$glib_size_t in
x2) echo "typedef gint16 gssize;" >> $outfile
echo "typedef guint16 gsize;" >> $outfile
;;
x4) echo "typedef gint32 gssize;" >> $outfile
echo "typedef guint32 gsize;" >> $outfile
;;
x8) echo "typedef gint64 gssize;" >> $outfile
echo "typedef guint64 gsize;" >> $outfile
;;
*) echo "#error size of size_t is unknown" >> $outfile
;;
esac
===> gsize evaluates to guint32;
case 4 in
$ac_cv_sizeof_short)
gint32=short
gint32_format='"hi"'
guint32_format='"hu"'
;;
$ac_cv_sizeof_int)
gint32=int
gint32_format='"i"'
guint32_format='"u"'
;;
$ac_cv_sizeof_long)
gint32=long
gint32_format='"li"'
guint32_format='"lu"'
;;
esac
===> guint32 evaluates to unsigned int
===> gsize is unsigned int and not unsigned long as declared in the system header
The xlc complains at many places about the use gsize where size_t was expected.
(unsigned int vs. unsigned long) especially for iconv call where two (size_t *)
parameter are expected and (gsize *) are suplied in gconvert.c.
extern size_t iconv(iconv_t, const char**, size_t*, char**, size_t*);
size_t
g_iconv (GIConv converter,
gchar **inbuf,
gsize *inbytes_left,
gchar **outbuf,
gsize *outbytes_left)
{
iconv_t cd = (iconv_t)converter;
return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
}
--
Miroslaw Dobrzanski-Neumann
MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]