Pelles C forum
Pelles C => Bug reports => Topic started by: frankie on July 22, 2018, 06:50:52 PM
-
In the header "wchar.h" there is a wrong definition of FILE, defining it only in the structures namespace:
struct FILE;
When using the library extension 2, defining __STDC_WANT_LIB_EXT2__ , the compiler complains on the extended functions definitions.
The error doesn't appear if the inclusion of wchar.c follows stdio.h, because the latter includes a correct definition for FILE structure.
I.e. the following code will fail.
#define __STDC_WANT_LIB_EXT2__ 1
#include <wchar.h> //Move declaration after stdio.h inclusion to make it compile
#include <stdio.h>
int main(void)
{
printf("<wchar.h> Bug V9.00\n");
}
To fix replace the wchar.h line above with the following that correctly define FILE structure at global namespace.
typedef struct FILE FILE;
-
I think a better idea is to add the keyword struct before FILE in the block guarded by __STDC_WANT_LIB_EXT2__ - like in other places of wchar.h.
Should be fixed now.
-
Of course it's the same. :)
I was using the typedef definition from <stdio.h>, where you declare the complete FILE structure in global and structures namespaces.
-
It's not the same, which was the whole point. Try compiling your solution and example in C99 mode without extensions enabled.
Anyway, case fixed and closed.
-
Sorry, you're right (as always more or less :D).
I forget that duplication of identical typedef's is specific of C11, as per ISO/IEC 9899:2011 ยง6.7/3 Declarations:
If an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space, except that a typedef name can be redefined to denote the same type as it currently does and tags may be redeclared as specified in 6.7.2.3.
For completeness the C99 standard miss the last sentence:
If an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space, except for tags as specified in 6.7.2.3.