簡體   English   中英

預編譯頭IntelliSense錯誤

[英]Precompiled Headers IntelliSense Error

我正在處理的靜態庫項目中啟用了“預編譯頭”。 環顧其他StackOverflow問題,似乎#include“ stdafx.h”的關鍵位置在.cpp文件中,而不是.h文件中。

但是,當我在Visual Studio中執行此操作時,出現IntelliSense錯誤:

1 IntelliSense:PCH警告:標頭停止不能在宏或#if塊中。 未生成IntelliSense PCH文件。 .... \\ Common \\ Core \\ Geometry \\ Ellipsoid.h 9

即使出現此IntelliSense錯誤,靜態庫項目也可以成功編譯。

.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 "Common\Core\stdafx.h"
#include "Ellipsoid.h"

// ...

通過在頭文件中包含stdafx.h,intelliSense錯誤消失了。 這是使用預編譯頭的正確方法嗎? 在頭文件中包含stdafx.h有什么含義?

您必須在文件的開頭添加一次#pragma Answere在這里: PCH警告:標頭停止不能在宏或#if塊中-Visual C ++ 2010 Express SP1 macro-or-if-block-visual-c-2010 -exp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM