[gl2ps] index conflicts with <string.h> header file

Daniel J Sebald daniel.sebald at ieee.org
Mon Sep 3 02:00:17 CEST 2012


Just a followup on this post:

> In gl2ps.c are a few instances of a variable called "index".  There is a
> global name "index" via <string.h> header that creates a
> shadow-global-name warning when compiled.  A simple fix is to change the
> name of the variable in a half dozen places.

Perhaps I wasn't clear on where the shadow warnings come from.  Try the 
following compilation command in the gl2ps source tree:

gcc -c -Wshadow gl2ps.c

Because <string.h> is included in gl2ps.c, there is a conflict between 
the global library function "index" and the variable "index".  It's 
inconsequential because gl2ps is not using the "index" function. 
Ridding the warnings would be nice.  I've attached a patch that replaces 
the variable "index" with "idx".  Try

patch < gl2ps_replaceindexwithidx_2012sep02.patch
gcc -c -Wshadow gl2ps.c

Thanks,

Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gl2ps_replaceindexwithidx_2012sep02.patch
Type: text/x-patch
Size: 6093 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gl2ps/attachments/20120902/bf47ad35/attachment.patch>