__stat64, redefinition; different type when including sys\stat.h after wchar.h

#include<windows.h>
#include<wchar.h>
__stat64 a;
#include<sys\stat.h>
__stat64 b;// <-- compiler error


Example compiler output:

d:\temp\t3test1\t3test1\stdafx.h(20) : error C2146: syntax error : missing ';' before identifier 'b'
d:\temp\t3test1\t3test1\stdafx.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\temp\t3test1\t3test1\stdafx.h(20) : error C2373: '_stat64' : redefinition; different type modifiers
c:\program files\microsoft visual studio 8\vc\include\sys\stat.h(237) : see declaration of '_stat64'
d:\temp\t3test1\t3test1\stdafx.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

[1367 byte] By [SteveHills] at [2007-12-16]
# 1
In VS.NET 2005 Beta 2.
SteveHills at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 2
This is due to the various _stat structures having identical names as the functions that you call to fill them. In order to make this work you'll need to specify that the variables you define are structures. So instead of:

__stat64 a;

you should:

struct __stat64 a;

-Ron Pihlgren
VC++ Testing

RonPihlgren at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...