Do I need "-Wstrict-prototypes " when compiling C programs..?

Home Forums C-programming.. Do I need "-Wstrict-prototypes " when compiling C programs..?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2093 Reply
    Humble
    Keymaster

    Yes, I would say: What that option mean to you/compiler ?

           -Wstrict-prototypes (C and Objective-C only)
               Warn if a function is declared or defined without specifying the argument types.  (An old-style function definition is permitted
               without a warning if preceded by a declaration that specifies the argument types.)
    
    
    
    
    hmmm.. lets try to compile the same program which used in earlier topics.
    
    
    [hchiramm@humbles-lap C-Pgm]$ gcc -Wall -Wstrict-prototypes -ansi -pedantic -c compile.c 
    compile.c:3:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     int main ()
         ^
    [hchiramm@humbles-lap C-Pgm]$ 
    
    
    
    now change the program a bit by respecting the warning.. 
    
    
    
    
    
    # include <stdio.h>
    
    int main (int argc, char *argv[])
    {
    
    	printf ("\n I was told to compile ");
    	return 0;
    }
    [hchiramm@humbles-lap C-Pgm]$ 
    
    
    
    Recompile,
    
    
    [hchiramm@humbles-lap C-Pgm]$ gcc -Wall -Wstrict-prototypes -ansi -pedantic -c compile.c 
    [hchiramm@humbles-lap C-Pgm]$ 
    
    
    
    No Errors!! cool, but Is this option really required ? 
    
    depends.. find the answer .. but always good to have it in your compiler string..
Viewing 1 post (of 1 total)
Reply To: Do I need "-Wstrict-prototypes " when compiling C programs..?
Your information: