我有一个头文件 (head.h),我在其中定义了 boolean 值:
bool flag = false;
在 main.c 中,我有一个函数:
void WINAPI function (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
if (flag == false)
{
//Some action
flag = true;
}
}
即使 main.c 以以下行开头,也无法识别 boolean 值“flag”:
#include "head.h"
...为什么?
最佳答案
我相信你把 #include "head.h"
放在 main.c
的顶部(在 #include "stdafx.h"
之前) >) 并且您使用预编译 header (至少这是我能够使用 Visual Studio 重现您的问题的方式)。 #include "stdafx.h"
应该始终放在第一位。
关于c++ - 从另一个文件中的函数检查 header 中定义的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6002579/