0

I am trying to make a C++ program that makes use of the string.h and cJSON library. But when I build it, I get warning saying:

cJSON.c:1743: warning: declaration of 'index' shadows a global declaration
string.h:487: warning: shadowed declaration is here

These warning doesn't really affect the functionality of the program and the program runs as expected. But I am trying to build the program using AzDo pipelines for exporting it and the AzDo pipelines fails builds on warnings. So, I need to find a way to resolve these warnings. What can be the best way to resolve this?

Edit: cJSON.c 1743 line is this: static cJSON* get_array_item(const cJSON *array, size_t index) string.h 487 line is this: extern char *index (__const char *__s, int __c)

Shantanu Shinde
  • 932
  • 3
  • 23
  • 48
  • 2
    Don't use `` in a C++ program is a good first step. Does it still happen if you use `` instead? – sweenish Mar 09 '21 at 14:04
  • @sweenish actually I am not directly using `string.h` some other library I am using has that include – Shantanu Shinde Mar 09 '21 at 14:43
  • Show those lines in the question. – Pete Becker Mar 09 '21 at 14:51
  • @PeteBecker I added the lines – Shantanu Shinde Mar 10 '21 at 04:55
  • That's a really weird warning. It's saying that because there's an argument named `index` in the first line, that function won't be able to call the function named `index`. Of course, if that was, in fact, a problem, the implementor of `get_array_item` would have given that argument a different name. "Treat all warnings as errors" is a really bad policy because it causes this kind of problem. You might edit `cJSON.c` and change that name. – Pete Becker Mar 10 '21 at 14:21

0 Answers0