Visual Studio 2017更新后无法打开sys/types.h等头文件求助
Hey there, let's work through this frustrating issue you're facing after updating Visual Studio 2017. Those sys/types.h and sys/stat.h missing errors popping up in wchar.h (error code E1969) aren't standard for Windows VS setups, so let's walk through targeted fixes:
Verify Project SDK and Toolset Configuration
Right-click your project → Properties, then head to Configuration Properties > General.- Confirm the
Windows SDK Versionis set to a version you have installed (VS2017 typically works best with SDKs like 10.0.17763.0 or older compatible releases). - Double-check the
Platform Toolsetis set tov141(the official toolset for VS2017)—updates sometimes accidentally switch this to a newer/uninstalled version.
- Confirm the
Repair Visual Studio Installation
Open the Visual Studio Installer, find your VS2017 instance, and click Modify.- Ensure the required
Windows SDKcomponent (matching your project's configured version) is checked. - Make sure all core C++ development tools are enabled, then select the Repair option to fix any corrupted or missing system files.
- Ensure the required
Clean Up Include Directory Priorities
Go to Project Properties → Configuration Properties > C/C++ > General and look at theAdditional Include Directories.- Remove any Unix-style include paths (like those pointing to directories with
sys/subfolders) that might be overriding VS's default system header lookup. - Save changes and try recompiling.
- Remove any Unix-style include paths (like those pointing to directories with
Clear Project Build Cache
- Delete the
DebugandReleasefolders in your project directory manually. - In Solution Explorer, right-click your solution → Clean Solution, then right-click again → Rebuild Solution. This ensures no stale or corrupted build files are causing issues.
- Delete the
Check for Corrupted wchar.h File
The errors are originating inwchar.h, so it's possible this system header got modified or corrupted during the update.- Navigate to your VS2017 include directory (usually
C:\Program Files (x86)\Microsoft Visual Studio\2017\<Edition>\VC\Tools\MSVC\<version>\include). - Compare your
wchar.hwith a fresh copy from a working VS2017 installation, or replace it with a clean version if you have one—this can resolve unexpected references to Unix-style headers.
- Navigate to your VS2017 include directory (usually
A quick note: sys/types.h and sys/stat.h are Unix/Linux standard headers, so VS's Windows-focused standard library shouldn't be referencing them by default. This issue almost always ties back to misconfiguration, corrupted installation files, or accidental header modifications.
内容的提问来源于stack exchange,提问作者Silviu

