GCC错误无限循环

GCC Error Infinite While Loop

#include <stdio.h>

int number, total;

int main (void)
{
    total = 0;

    while (true) {
        printf ("Enter a number (-1 to stop)\n");
        scanf (" %d", &number);
        if (number < 0) {
            break;
        }

        total = number + total;
    }

    printf ("The total is %d", total);

    return 0;
}

当我在 OSX 上的 C 程序中使用 while (true) 循环时,出现以下错误

'error': use of undeclared identifier 'true' while (true)

然而,当我 运行 在我的 Windows 分区上(通过 GCC 程序)时,我没有收到任何错误..

这是 GCC 对 osx 的限制吗?

将以下内容添加到文件顶部:

#include <stdbool.h>

这将定义 booltruefalse