C Tips: stdbool.h
来源:互联网 发布:电磁炉哪个好 知乎 编辑:程序博客网 时间:2024/06/06 08:21
下面是来自 cprogramming.com 的 stdbool.h 的定义:
#ifndef STDBOOL_H_#define STDBOOL_H_ /** * stdbool.h - ISO C99 Boolean type * Author - Bill Chatfield * E-mail - bill underscore chatfield at yahoo dot com * Copyright - You are free to use for any purpose except illegal acts * Warrenty - None: don't blame me if it breaks something * * In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but * some compilers don't offer these yet. This header file is an * implementation of the standard ISO C99 stdbool.h header file. It checks * for various compiler versions and defines things that are missing in * those versions. * * The GNU and Watcom compilers include a stdbool.h, but the Borland * C/C++ 5.5.1 compiler and the Microsoft compilers do not. * * See http://predef.sourceforge.net/precomp.html for compile macros. */ /** * Borland C++ 5.5.1 does not define _Bool. */#ifdef __BORLANDC__typedef int _Bool;#endif /** * Microsoft C/C++ version 14.00.50727.762, which comes with Visual C++ 2005, * and version 15.00.30729.01, which comes with Visual C++ 2008, do not * define _Bool. */#if defined(_MSC_VER) && _MSC_VER <= 1500typedef int _Bool;#endif /** * Define the Boolean macros only if they are not already defined. */#ifndef __bool_true_false_are_defined#define bool _Bool#define false 0 #define true 1#define __bool_true_false_are_defined 1#endif #endif /*STDBOOL_H_*/
但是上述文件在 Visual Studio 2012 中不工作。
下面是我自己写的 stdbool.h 的定义:
#ifndef STDBOOL_H_#define STDBOOL_H_/** * stdbool.h * Author - Yaping Xin * E-mail - xinyp at live dot com * Copyright - You are free to use for any purpose except illegal acts * Warrenty - None: don't blame me if it breaks something * * In ISO C99, stdbool.h is a standard header and _Bool is a keyword, but * some compilers don't offer these yet. This header file is an * implementation of the stdbool.h header file. * */#ifndef _Booltypedef unsigned char _Bool;#endif /* _Bool */ /** * Define the Boolean macros only if they are not already defined. */#ifndef __bool_true_false_are_defined#define bool _Bool#define false 0 #define true 1#define __bool_true_false_are_defined 1#endif /* __bool_true_false_are_defined */ #endif /* STDBOOL_H_ */
参考链接:
- stdbool.h in Visual Studio C++ Express 2008 ( standard C code) http://cboard.cprogramming.com/c-programming/138189-stdbool-h-visual-studio-cplusplus-express-2008-standard-c-code.html
- Boolean data type http://en.wikipedia.org/wiki/Boolean_data_type#C99
- Where is stdbool.h? http://stackoverflow.com/questions/1656874/where-is-stdbool-h
0 0
- C Tips: stdbool.h
- C 语言 bool stdbool.h
- stdbool.h
- <stdbool.h>
- c语言中<stdbool.h>的使用
- C语言中的stdbool.h头文件
- C语言中的stdbool.h头文件
- c语言中<stdbool.h>的使用
- stdbool.h 的实现
- C语言没有bool类型, C99标准stdbool.h定义了一个_Bool的宏
- C语言之加入头文件<stdbool.h>可以使用true和false
- caffe windows Faster rcnn setup.py 找不到 stdbool.h 解决办法
- C tips
- c++,tips
- C tips
- C tips
- C Tips
- C++代码优化Tips
- 怎么办$HTTP POST与PHP AngularJS
- java基本数据类型和基本数据类型的转换
- 鸟哥的linux私房菜 mark2
- POJ 1141 Brackets Sequence(JAVA版)
- HTTP缓存思考
- C Tips: stdbool.h
- linux的文件权限与目录配置
- &和|与&&和||的区别
- poj 1862 Stripies 数学
- MFC笔记 RichEdit控件
- mysql 命令
- 小心 Spring MVC 使用陷阱
- Code in 2013
- linux(ubuntu)上安装配置redmine