c - why does the compiler give a warning for unused function? -


i have written sample program understand working of functions in c. declared function in c , call during programs execution. compiler gives me warning saying unused function. code looks :

 #include <stdlib.h>  #include <stdio.h>   int test_function(x);  int main(){       int x;      char letter[] ={"haaa"};      char cmpre[] = {"ahd"};      int value;       for(int i=0; i<4;i++)      {        if(letter[i] == cmpre[i])          {             x=0;          }      }       int test_function(x)         {           if (x==0)           {             printf("the letters same");           }          return value;         }     printf("to check if letters same go function");    test_function(x);     return 0;    } 

the program seems execute fine warning in fourth line declared function in start of program. warning :

  multiple markers @ line - parameter names (without types) in function declaration [enabled   default] - unused declaration of function 'test_function' 

i think way calling function not right. please me. thnak in advance.

disclaimer: nested functions non-standard c , know (of) gnu extension this. such claim here may untrue in implementation. recommendation don't use them @ all.

your nested test_function shadowing global declaration. test_function declared above main never called, because call inside main refers nested function. hence, warning.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -