PCH Warning in Visual C++

The following error was observed in Microsoft Visual C++ 2010 edition.

Error:
Error: PCH Warning: header stop cannot be in a macro or #if block. An intellisense PCH file was not generated.

Problem code:

[file name : perCoreUsage.h] 

#ifndef perCoreUsage
#define perCoreUsage

void perCoreUsageCall();

#endif

Solution-1

Add the following line in your header file perCoreUsage.h:
#pragma once

Solution-2

Use your header file in some CPP file like perCoreUsage.cpp or main.cpp:
#include "perCoreUsage.h"

This Visual C++ IntelliSense warning, header stop cannot be in a macro or if block, means the precompiled header boundary fell inside an include guard or conditional, so no precompiled header was generated.

Moving the include guard, or restructuring the header so the first includes are not wrapped in the conditional, lets the precompiled header build again. It affects IntelliSense rather than the final compiled output.

Comments

Popular posts from this blog

[Solved] Error: No such keg: /usr/local/Cellar/gcc

[How To] Unfollow Non-followers on Instagram