[PATCH 1/2] xf86Config: Fix warning: declaration of 'Pointer' shadows a global

Hans de Goede hdegoede at redhat.com
Mon Mar 3 02:31:35 PST 2014


Hi,

On 03/03/2014 11:23 AM, Mark Kettenis wrote:
>> From: Hans de Goede <hdegoede at redhat.com>
>> Date: Mon,  3 Mar 2014 09:53:12 +0100
>>
>> This fixes the following compiler warning:
>>
>> xf86Config.c: In function 'checkCoreInputDevices':
>> xf86Config.c:1136:18: warning: declaration of 'Pointer' shadows a global declaration [-Wshadow]
>>      InputInfoPtr Pointer, Keyboard;
>>                   ^
>> In file included from xf86Xinput.h:57:0,
>>                  from xf86Config.c:66:
>> /opt/xorg/include/X11/extensions/XIproto.h:88:24: warning: shadowed declaration is here [-Wshadow]
>>  typedef unsigned char *Pointer;
> 
> Your compiler is on drugs.  Pointer is a typedef, which is a
> completely different namespace from variable names.

No it is not, you're assuming the compiler can always infer which
namespace it should use which it cannot, ie:

(Pointer) -foo

Is this casting -foo to a Pointer, or is this substracting the
value in foo from the value in Pointer ?

The compiler cannot know, so the 2 namespace do overlap in a way,
and the shadowing can lead to unexpected results when a cast
is intended and it becomes something else instead.

Regards,

Hans


More information about the xorg-devel mailing list