Since installing RC6 of PellesC v8 I have been having issues when wchar.h and windows.h are used together. Here is and example compile error I am seeing when wchar.h is included before windows.h:
C:\PellesC\Include\wchar.h(267): error #2095: Expected type for parameter 4, but found 'FILE'.
C:\PellesC\Include\wchar.h(267): error #2048: Undeclared identifier 'FILE' (did you mean 'HFILE'?).
C:\PellesC\Include\wchar.h(268): error #2095: Expected type for parameter 3, but found 'FILE'.
C:\PellesC\Include\wchar.h(268): error #2048: Undeclared identifier 'FILE' (did you mean 'HFILE'?).
If I include wchar.h after windows.h I get:
C:\PellesC\Include\wchar.h(267): error #2095: Expected type for parameter 4, but found 'FILE'.
C:\PellesC\Include\wchar.h(267): warning #2099: Missing type specifier; assuming 'int'.
C:\PellesC\Include\wchar.h(267): error #2001: Syntax error: expected ')' but found '*'.
C:\PellesC\Include\wchar.h(267): error #2001: Syntax error: expected ';' but found ')'.
C:\PellesC\Include\wchar.h(268): error #2095: Expected type for parameter 3, but found 'FILE'.
C:\PellesC\Include\wchar.h(268): warning #2099: Missing type specifier; assuming 'int'.
C:\PellesC\Include\wchar.h(268): error #2001: Syntax error: expected ')' but found '*'.
C:\PellesC\Include\wchar.h(268): error #2001: Syntax error: expected ';' but found ')'
Both __STDC_WANT_LIB_EXT1__ and __STDC_WANT_LIB_EXT2__ are defined as part of my flags passed to pocc.
At first I thought it was me and I had introduced some bug in my code somewhere but I have been pulling my hair out for many hours now and as long as wchar.h and windows.h are in the same compile I get this issue so I am thinking its not me after all :(
Any ideas?
I knew the moment I posted here that I would finally sort it out...
I needed the /Zx compiler option.
Actually I take that back. I just added wchar.h into a source file from the glfw library to get at wcslen(), which is not in string.h as it is in other std library implementations and up pops that error again:
C:\PellesC\Include\wchar.h(267): error #2095: Expected type for parameter 4, but found 'FILE'.
C:\PellesC\Include\wchar.h(267): error #2048: Undeclared identifier 'FILE' (did you mean 'HFILE'?).
C:\PellesC\Include\wchar.h(268): error #2095: Expected type for parameter 3, but found 'FILE'.
C:\PellesC\Include\wchar.h(268): error #2048: Undeclared identifier 'FILE' (did you mean 'HFILE'?).
Has something been broken in wchar.h or windows.h between RC5 and RC6?
EDIT: Further to the above this error only occurs with __STDC_WANT_LIB_EXT2__ defined.
wchar.h uses struct FILE if you define __STDC_WANT_LIB_EXT2__,
so include stdio.h first.
John
Thanks John, you're a genius, or should I say that I am not ;)
Yes, well I don't think the word genius fits well with the view of myself. :)
John