howto get rid of 'pointer arguments differ in signedness'
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Wed, 06 Jun 2007 12:04:53 +0200
Excuse me if this is still common knowledge, but there is reason to
believe in the opposite ...
Since gcc 4, gcc has acquired the annoying habit to warn about
sign differences in pointed-to types, for instance, as in
#include <stdio.h>
#include <string.h>
int main(void)
{
unsigned char buf[256];
gets(buf); /* dear ld, this a toy example program */
if (strcmp(buf, "abc") == 0) puts("def!");
return 0;
}
When compiled with -Wall, this will result in the following output:
a.c: In function 'main':
a.c:8: warning: pointer targets in passing argument 1 of 'gets' differ in signedness
a.c:9: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness
/tmp/cc4kzfkW.o: In function `main':
a.c:(.text+0x20): warning: the `gets' function is dangerous and should not be used.
The idea of the gcc-team in this respect appears to be that everybody
must change every ocurrence of a certain construct in all inherited
sources whenever the gcc-team choses to (again) change the behaviour
of its fscking 'product' (If you have the option of using a compiler
whose developers have an interest in not causing their users needless
troubles, you should certainly do so. With 4, the people that used
to break random C++ sources differently with each release have
apparently turned their attention to the C-compiler and this matter
will get worse).
If you are so unfortunate that you have to use 'linty freeware
available on the internet' to compile large amounts of legacy code
(and, like me, are using different releases of those 'linty
freeware'), there is (at least there still is) a way to get rid of
this nonsense. gcc is just a driver program that calls other binaries
to perform the actual work in a way that is defined by a set of
so-called 'spec strings', which describe what commandline switches
need to be passed how to which programs. This mechansim can be used to
selectively disable certain warnings for particular gcc versions.
For gcc-4.1.2 on Debian stable, the procedure is (as root):
cd /usr/lib/gcc/i486-linux-gnu/4.1.2
gcc -dumpspecs >specs
and then to add %{!Wpointer-sign:-Wno-pointer-sign} to the
line below *cc1_options:. This will disable warnings about sign
differences in pointed-to types unless specifically requested.
.
- Follow-Ups:
- Re: howto get rid of 'pointer arguments differ in signedness'
- From: Dildo Baggins
- Re: howto get rid of 'pointer arguments differ in signedness'
- From: David Schwartz
- Re: howto get rid of 'pointer arguments differ in signedness'
- From: Tim Southerwood
- Re: howto get rid of 'pointer arguments differ in signedness'
- From: Joe Pfeiffer
- Re: howto get rid of 'pointer arguments differ in signedness'
- Prev by Date: Re: Programmatic authentication...
- Next by Date: Re: Changing libraries when they are already in process space
- Previous by thread: permissions - again...
- Next by thread: Re: howto get rid of 'pointer arguments differ in signedness'
- Index(es):
Relevant Pages
|