Is <stdio.h> include needed for FILE in C?
I have a header file (sample.h) for my c file (sample.c). When I prototyped a function in my header file as below.
return_type sample_fun (FILE *filePtr);
I get a compilation error saying, Syntax error: possible missing ')' or ','? When I include the stdio.h error is resolved. Is the stdio.h include 开发者_如何学Pythonmandatory? Some of my files work well without the include.
I use gcc on AIX.
Yes, the type FILE is defined in stdio.h; if you mention it, then you must include that file.
Yes it is. FILE is typedefed from a struct iobuf on most platforms. This requires that the full definition of struct iobuf be present, even though all the interfaces use FILE *, and pointer types do not normally require full definitions prior to their use (C limitation).
See this question for more information: Forward declare FILE *
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论