`
james23dier
  • 浏览: 526005 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

linux 不支持while(true)吗?

阅读更多

今天闲来无事,竟然写了个while(true),然而结果也非常让我吃惊。结果竟然编译错误。。下面是我的源代码:

#include<stdio.h>

int main(){
        while ( true ){
                break;
        }
        return 0;
}

 采用gcc4.1.2编译,错误信息如下所示:

gcc test_true.c
test_true.c: In function 'main':
test_true.c:4: error: 'true' undeclared (first use in this function)
test_true.c:4: error: (Each undeclared identifier is reported only once
test_true.c:4: error: for each function it appears in.)
也就是说while循环把true当做了变量,而不是内置关键字。。

 

 

经过今天查询得知:和我采用的gcc编译器有关。gcc不支持,但是g++支持。这是因为true并非c99标准关键字。c99中的bool类型采用关键字_Bool声明,而且形如_Bool a = true;这种语句使用gcc不能编译通过的。但是如果要使用,使用g++进行编译即可。或者使用_Bool a = 1;这种形式。

分享到:
评论

相关推荐

    linux上通过sh方式启动java jar程序并做为守护进程

    NULL 博文链接:https://qsfwy.iteye.com/blog/1650426

    LINUX安装与配置简明手册

    本书详细介绍如何在个人电脑上安装配置Caldera和Red Hat两种发行版本的Linux操作系统,并能帮助用户解决安装和配置过程中出现的各种问题。本书既能指导你进行基本的安装步骤,也能指导你定制独具特色的Linux 操作...

    Linux如何查看进程栈信息示例

    今天在Linux上调试程序程序的时候发现有时候程序会莫名其妙的hang住,于是就想能不能找到当时程序有那些线程,都在做什么。找了一下linux命令,还真可以满足我的需求。下面看一个小例子。 先准备一段程序,为了简单...

    Linux用户的3个命令行小技巧

    Linux世界充满了乐趣,我们越深入进去,会发现越多有趣的事物。我们会努力给你提供一些小技巧,让你和其他人有所不同,下面是我们准备的3个小技巧。  1. 如何在不使用Cron的情况调度Linux...  $ while true; do dat

    led linux c源程序

    // 返回值: 添加成功返回 TRUE,否则返回 FALSE(例如超过最大菜单项数) //-------------------------------------------------------------------------------- BOOL MenuAppendItem(PPOSMENU pMenu, const char *...

    JAVA——linux

    i++){ //取不重复的红球 int idx; do{ idx = r.nextInt(red.length);//随机数:0~32 }while(used[idx]);//如果使用了,继续找下一个 used[idx] = true;//标记使用了 all[i] = red[idx];//取出一个未使用的红球 ...

    Python脚本后台运行的几种方式

    一个用python写的监控脚本test1.py,用while True方式一直运行,在ssh远程(使用putty终端)时通过以下命令启动脚本: 代码如下: python test1.py & 现在脚本正常运行,通过ps能看到进程号,此时直接关闭ssh终端...

    linux安装与配置简明手册

    本书详细介绍如何在个人电脑上安装配置Caldera和Red Hat两种发行版本的Linux操作系统,并能帮助用户解决安装和配置过程中出现的各种问题。本书既能指导你进行基本的安装步骤,也能指导你定制独具特色的Linux 操作...

    2048.ko:在Linux内核中播放2048

    2048.ko-在Linux内核中播放2048 这个... while true; do cat /proc/play_2048; sleep 0.1; done& while IFS= read -r -n1 c; do echo $c &gt; /proc/play_2048; done'使用Ctrl-C取消。 使用箭头键或wasd或hjkl移动图块

    uos(Debian系linux)安装lm-sensors,监控温度并写入文本文件

    #!/bin/bash sudo apt install lm-sensors while true;do echo $(sensors) &gt;&gt; temprature.txt;echo $(uptime) &gt;&gt; temprature.txt;sleep 30;done chmod +x 双击终端中或者 终端中bash record_temp.sh

    8-07-14_MegaCLI for linux_windows

    SCGCQ00318641 EnhancementRequest True Online Firmware Update SCGCQ00322216 EnhancementRequest Help files for Perfmode in adp(set/get)prop are added. SCGCQ00322234 EnhancementRequest Utilities to show ...

    ansible-role-srv_kvm:Ansible角色,用于安装和配置kvm主机

    角色:srv_kvm Ansible角色,用于... ansible-galaxy install while_true_do.srv_kvm 从Github安装 git clone https://github.com/while-true-do/ansible-role-srv_kvm.git while_true_do.srv_kvm 用法 角色变量

    Addison.Wesley.Advanced.Programming.in.the.UNIX.Environment.Second.Edition.chm

    Stephen Rago has successfully revised this book to incorporate newer operating systems such as GNU/Linux and Apple's OS X while keeping true to the first edition in terms of both readability and ...

    Ubuntu权威指南(2/2)

    5.15.4 检索不包含特定字符 ??串的文本行 129 5.15.5 在grep中使用正则 ??表达式 129 5.15.6 检索元字符本身 131 5.15.7 在命令行中使用引号 131 5.16 排序 132 第6章 编辑文件 133 6.1 启动vim编辑器 134 6.1.1 ...

    Ubuntu权威指南(1/2)

    5.15.4 检索不包含特定字符 ??串的文本行 129 5.15.5 在grep中使用正则 ??表达式 129 5.15.6 检索元字符本身 131 5.15.7 在命令行中使用引号 131 5.16 排序 132 第6章 编辑文件 133 6.1 启动vim编辑器 134 6.1.1 ...

    python实现员工管理系统

    2.while True 以及给while做退出层级标记 3.if…elif…else 的嵌套使用 4.continue 和 break 以及简单函数定义def 5.键盘抓取 raw_input 以及通过 os.system&#40;‘clear’&#41;来调用linux中shel

    ganymed-ssh2-build210.jar java远程访问linux服务器操作、上传下载文件

    java远程访问linux服务器操作 远程执行shll脚本或者命令、上传下载文件 package com.szkingdom.kfit.bank.ccbDirectShortcut.helper; import ch.ethz.ssh2.Connection; import ch.ethz.ssh2.SCPClient; import ...

    Linux中nohup与&的用法和区别详解

    while True: i += 1 print('%d: hello world!' %(i)) time.sleep(1) if '__main__' == __name__: main() 运行loop_hello.py,输出结果如下: 程序每隔一秒会在终端输出一个字符串,此时如果键入Ctrl+C ,程序...

    minimal_perl_for_unix_and_linux_people.pdf

    the simple idea that B should be executed only if A is True (with those letters repre- senting arbitrary program elements). Both forward and backward variations for expressing the dependency are ...

    Linux服务器网卡流量查看方法 shell和Python各一枚

    脚本中都用了while true“死循环”,每隔10s从“/proc/net/dev”中取一次值并根据10s内的差值计算10s内的平均带宽;按ctrl+c停止执行。脚本兼容centos6和7 两个脚本都不太复杂,而且脚本中注释也比较细致,所以我就...

Global site tag (gtag.js) - Google Analytics