gpt4 book ai didi

c - 如何在 Visual Studio 2015 中将 header 编译器更改为 C 编译器(不是 C++)

转载 作者:行者123 更新时间:2023-11-30 16:59:54 29 4
gpt4 key购买 nike

例如我有

myheader.h

#include <stdbool.h>

_Bool foo()
{
return true;
}

对于 cpp 文件,我只需将 *.cpp 更改为 *.c

但是如何在Visual Studio 2015中将头文件编译器更改为C编译器

最佳答案

“stdbool.h”是一个C99头文件。 Microsoft 的 C/C++ 编译器不支持它,而且可能永远不会。 MSVC 2013 及更高版本似乎支持 C99。我的错。

你可以:

  1. 寻找另一个编译器

  2. 使用黑客:

    typedef int bool;
    #define false 0
    #define true 1

  3. 切换到 C++,它具有 native bool 类型。

我个人推荐第三种。

<小时/>

有关该主题的更多阅读:trying to use '#include <stdbool.h>' in VS 2010

关于c - 如何在 Visual Studio 2015 中将 header 编译器更改为 C 编译器(不是 C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37918363/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com