在刷题的时候,使用万能头文件 #include,但是vscode无法识别,找不到头文件。
问题出在路径中没有这个文件,所以创建这个文件。
红波浪线报错
解决方案,亲测有效
在代码的头文件加入#include,右键转到定义
屏幕快照 2020-09-14 11.56.46.png
在打开的iostream文件上右键“在finder中显示”,找到该文件所在的文件夹(win系统同理)
屏幕快照 2020-09-14 12.20.23.png
在该文件夹下,新建一个txt文件,将名称改为stdc++.h,粘贴下面这段内容到里面,并将文件保存在此。
屏幕快照 2020-09-14 12.21.44.png
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2014 Free Software Foundation, Inc. This file is part of the GNU ISO C++ Library. This library is free// software; you can redistribute it and/or modify it under the// terms of the GNU General Public License as published by the// Free Software Foundation; either version 3, or (at your option)// any later version.
// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional// permissions described in the GCC Runtime Library Exception, version// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and// a copy of the GCC Runtime Library Exception along with this program;// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see// .
/** @file stdc++.h * This is an implementation file for a precompiled header. */
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if __cplusplus >= 201103L
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
// C++
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if __cplusplus >= 201103L
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
现在再运行代码#include,应该就没问题了。
(或者在上述iostream同级文件夹下新建一个文件夹bits,将stdc++.h编辑好后放进其中,在使用的时候写成#include也可以。