G
guisep4
I have unusual "problem" with naming local variable "index".
It all began when I added -Wshadow [1] to gcc commandline.
The code is like this:
#include <string.h>
int foo(void) {
int index; /* WARNING here */
for(index = 0; index < MAX; index++) { ...
With '-Wshadow', this innocent code spits the warning:
file.c:4: warning: declaration of 'index' shadows a global
declaration
/usr/include/string.h:304: warning: shadowed declaration is here
I want to keep -Wshadow so I need to rename the local var. But I
like the word "index" in this case. So I am looking for a legal
variation,
like _index or index_. Uppercase letters are out. My question is,
according to the common unix coding style (not hungarian and not
CamelCase), would index_ or _index be acceptable ?
I suggest we take a poll and I'll count the votes afterwards
Which other modification of "index" word would you
suggest to avoid name collision in this case ?
[1]
-Wshadow
Warn whenever a local variable shadows another local variable,
parameter or global variable or whenever a built-in function is
shadowed.
It all began when I added -Wshadow [1] to gcc commandline.
The code is like this:
#include <string.h>
int foo(void) {
int index; /* WARNING here */
for(index = 0; index < MAX; index++) { ...
With '-Wshadow', this innocent code spits the warning:
file.c:4: warning: declaration of 'index' shadows a global
declaration
/usr/include/string.h:304: warning: shadowed declaration is here
I want to keep -Wshadow so I need to rename the local var. But I
like the word "index" in this case. So I am looking for a legal
variation,
like _index or index_. Uppercase letters are out. My question is,
according to the common unix coding style (not hungarian and not
CamelCase), would index_ or _index be acceptable ?
I suggest we take a poll and I'll count the votes afterwards
Which other modification of "index" word would you
suggest to avoid name collision in this case ?
[1]
-Wshadow
Warn whenever a local variable shadows another local variable,
parameter or global variable or whenever a built-in function is
shadowed.