I have a header file (head.h) in which I define the boolean value:
bool flag = false;
In main.c, I have a function:
void WINAPI function (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
if (flag == false)
{
//Some action
flag = true;
}
}
The boolean value ‘flag’ is not recognised even though main.c starts with the line:
#include "head.h"
…Why?
I believe you put
#include "head.h"at the top ofmain.c(before#include "stdafx.h") and you use precompiled header(at least it’s how I’m able to reproduce your issue with Visual Studio).#include "stdafx.h"should always go first .