Windows下VS Code C语言标准头文件报错

在Windows下运行run

执行gcc -v -E -x c++ -提示没有gcc命令

下载安装mingw-w64

离线版下载地址:https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z/download

解压

[root@localhost VScode]# 7za  x  x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z

Windows下添加环境变量:

右击我的电脑-》属性-》高级系统设置-》环境变量-》编辑-》新建

复制解压后工具链bin文件的路径: Z:\tools\VScode\mingw64\bin

在Windows运行run里执行 0k

C:\Users\Administrator>gcc -v -E -x c++ -
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64 --enable-shared --enable-static --enable-targets=all --enable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-sjlj-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project)
COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=core2' '-march=nocona'
 Z:/tools/VScode/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/cc1plus.exe -E -quiet -v -iprefix Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/ -D_REENTRANT - -mtune=core2 -march=nocona
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++"
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32"
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward"
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include"
ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../include"
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"
ignoring duplicate directory "Z:/tools/VScode/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-sjlj-rt_v6-rev0/mingw64/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed
 Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include
End of search list.

打开VS code,点击右下角Win32 Edit Configuarations Json

在c_cpp_properties.json文件里将上面search的添加到里面:

{

    "configurations": [

        {

            "name": "Win32",

            "includePath": [

                "${workspaceFolder}/**"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"

                "Z:/tools/VScode/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"

            ],

            "defines": [

                "_DEBUG",

                "UNICODE",

                "_UNICODE"

            ],

            "intelliSenseMode": "msvc-x64"

        }

    ],

    "version": 4

}

重启VS Code , 头文件提示不在 消失。

 

 

你可能感兴趣的:(工具)