Visual Studio 2017 Intellisense error

closed account (DEhqDjzh)
1
2
Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E2904	PCH warning: header stop not at file scope.  An IntelliSense PCH file was not generated.	FCEC	c:\Users\lenovo\Desktop\Code Stuff The IV\FCEC\FCEC\main.c	4	 

In my C projects, I get this error on the same line with #include "Engine.h"

How to fix this

Can you show your Engine.h file?

PCH stands for pre-compiled header, by the way. Does your actual program still compile?

See also https://stackoverflow.com/questions/9025537/visual-studio-2010-c-intellisense-error
Last edited on
small projects, you can often quick fix this by delete the intelisense file and it will rebuild a working one.
closed account (DEhqDjzh)

@Ganado

Engine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
#pragma once

#include <stdio.h>
#include <SDL.h>

#define bool	_Bool // stdbool.h
#define false	0
#define true	1
bool gameisrunning;
SDL_Event event;

void getinput();



struct Engine
{

	int test;
};

Last edited on
Did you forget to #include <stdafx.h> in main.c? If your project uses precompiled headers, this line must be the first non-comment line in every .c and .cpp file.
closed account (DEhqDjzh)
there is no file called stdafx.h in my project or includes
1
2
bool gameisrunning;
SDL_Event event;

This may be unrelated to your problem, but: what are you doing to avoid multiple redefinition of global variables?
closed account (DEhqDjzh)
Found the Solution! Removing #pragma once solved the problem
I'm not exactly sure why that fixes it, but please note that you should have proper header guards in C and C++. (Most if not all compilers support #pragma once, but it's technically non-standard).

This means something like:

1
2
3
4
5
6
7
8
#ifndef ENGINE_H_HEADER_GUARD
#define ENGINE_H_HEADER_GUARD

#include <other_stuff>

struct Whatever {  };

#endif // ENGINE_H_HEADER_GUARD 


where "ENGINE_H_HEADER_GUARD" needs to be a unique macro token.
Topic archived. No new replies allowed.