How do I forward declare FILE * in C? I normally do this using struct MyType;, but naturally this doesn’t appear to be possible.
If behaviour differs between C standards or compilers and with C++, this is also of interest.
Update0
Why I want to do this aside: What I’m asking is how to forward declare a non-struct/”typedef’d struct” type so that I can declare pointers to it. Obviously using void * and casting it in the source file is a bit hackish.
You can’t. The standard just states that
FILEis “an object type capable of recording all the information needed to control a stream”; it’s up to the implementation whether this is atypedefof astruct(whose name you don’t know anyway), or something else.The only portable way to declare
FILEis with#include <stdio.h>(or<cstdio>in C++).