c++filepointersvisual-c++-2008

Odd error: 'FILE *' differs in levels of indirection from 'FILE'


I've seen people with a similar problem involving other file types, but nothing directly addressing FILE. As stated in the title, the error reads 'FILE *' differs in levels of indirection from 'FILE'.

In my main.h, I included <stdio.h>, which, if I recall correctly, is the only standard library that has the FILE stream type in it. Then, in one header, I have extern FILE *gvLog;. I only included <stdio.h> in main.h, and I have used #ifndef _MAINH_ to prevent it from being included twice, so why am I getting this error? What does it mean?


Solution

  • The 'levels of indirection' language means that one is a type and the other is a pointer to that type. In this case, FILE is a type and FILE* is a pointer to that type. You are using one where the other was expected, most likely you are passing *gvLog (an object of type FILE) to a stdio function that expects a FILE* (a pointer to an object of type FILE).