预编译标头智能感知错误

Precompiled Headers IntelliSense Error

本文关键字:感知 错误 智能 编译      更新时间:2023-10-16

>我在我正在处理的静态库项目中启用了预编译标头。环顾其他StackOverflow问题,似乎 #include"stdafx.h"的关键位置是在.cpp文件中,而不是.h文件中。

但是,当我在Visual Studio中执行此操作时,我收到一个IntelliSense错误:

1 智能感知:PCH 警告:标头停止不能位于宏或 #if 块中。 未生成智能感知 PCH 文件。....\通用\核心\几何\椭圆体.h 9

静态库项目确实成功编译,即使出现此智能感知错误也是如此。

.h文件由以下类声明组成:

#ifndef GEOMETRY_ELLIPSOID_H
#define GEOMETRY_ELLIPSOID_H
class Ellipsoid { // 'class' is underlined with a red line (error)
    // ...
};
#endif // !GEOMETRY_ELLIPSOID_H

.cpp定义标头中声明的类:

#include "CommonCorestdafx.h"
#include "Ellipsoid.h"
// ...

通过在标头中包含 stdafx.h,intelliSense 错误将消失。这是使用预编译标头的正确方法吗?在标头中包含 stdafx.h 有什么含义?

您必须

在文件开头添加一次 #pragmaAnsare 在这里: PCH 警告: 标头停止不能在宏或 #if 块 - Visual C++ 2010 Express SP1宏观或如果块视觉 C-2010-exp