如何停止 IntelliSense PCH 警告? [英] How do I stop an IntelliSense PCH Warning?

查看:42
本文介绍了如何停止 IntelliSense PCH 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一些头文件没有包含,所以我在 Visual Studio 2010 中收到此消息:

A few of my header files have no includes, so I receive this message in Visual Studio 2010:

IntelliSense: PCH warning: cannot find a suitable header stop location.  An intellisense PCH file was not generated.

如果我添加一个标题,例如:

If I add a single header, for instance:

#include <iostream>

它消失了.如何在不添加(可能未使用的)包含的情况下阻止显示此错误>

It disappears. How can I stop this error from showing without adding (potentially unused) include>

推荐答案

添加 .cpp 文件时,它会继承项目的 PCH 设置.问题更详细的解释这里

When adding a .cpp file it inherits the PCH settings of the project. More detailed explanation of the problem here

解决方案:

  1. 在文件开头添加#pragma once.

这将导致您的源文件在单个编译中只包含一次,因此编译器将得到满足并且不需要额外的 #include

It will cause your source file to be included only once in a single compilation, therefore the compiler will be satisfied and won't require additional #include

  1. 将您的项目设置为不使用预编译头文件
  2. 为您添加的那个 cpp 文件禁用 PCH 使用,这将清除 IntelliSense 和编译器警告/错误.

注意!我将 num 2 和 3 包括在内,因为有人说它有帮助,但只有 num 1 确实解决了我的问题.

Note! I'm including num 2, and 3 because some say it helped, but it only num 1 that did solve my case.

这篇关于如何停止 IntelliSense PCH 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆