检查在另一个文件中头文件中定义从一个函数值 [英] Checking a value defined in a header from a function in another file

查看:162
本文介绍了检查在另一个文件中头文件中定义从一个函数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个头文件(head.h)中,我定义了布尔值:

I have a header file (head.h) in which I define the boolean value:

bool flag = false;

在main.c中,我有一个函数:

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;
    }
}

Boolean值'标志',即使main.c中的行开始无法识别:

The boolean value 'flag' is not recognised even though main.c starts with the line:

#include "head.h"

...为什么?

...Why?

推荐答案

我相信你把的#includehead.h在顶部的main.c (前的#includestdafx.h中),并使用precompiled头(至少是我是如何能够再现与Visual Studio您的问题)。 的#includestdafx.h中应该总是先走了。

I believe you put #include "head.h" at the top of main.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 .

这篇关于检查在另一个文件中头文件中定义从一个函数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆