0

dictionary.c:30:24: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] bool check(const char* word) ^

dictionary.c:24:6: note: previous declaration is here char word[LENGTH + 1]; ^

dictionary.c:100:22: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] int hash(const char* word) ^

dictionary.c:24:6: note: previous declaration is here char word[LENGTH + 1]; ^

1

You have a global variable word, and you have function parameters named word. Within those functions, word would always refer to the function parameter, while the global variable will be "shadowed" by the parameter, and not be accessible by its name. That's why this is a warning, and with -Werror an error.

There are multiple possible solutions.

  1. Rename one or the other, so there's no possible name conflict
  2. Determine whether the global variable makes sense, or if it might be better to declare it locally where needed (load?). Without the global variable, there's also no conflict (unless you declare it within check or hash).
5
  • thank you it worked but now it shows me the error that dictionary,h is not found even though it is the same directory??help me plez Jun 19 '18 at 13:22
  • Maybe you used <dictionary.h> instead of "dictionary.h", or have a typo.
    – Blauelf
    Jun 19 '18 at 16:05
  • still it shows me same error.... #include <dictionary.h> ^ 1 error generated. Jun 19 '18 at 16:39
  • Should be quotation marks. Use angle brackets only for libraries. Does ls list all the files?
    – Blauelf
    Jun 19 '18 at 17:29
  • yes it does show me all the files within the directory... Jun 19 '18 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .