C语言Bool型转int型,布尔型 转 整型

情到浓时终转凉″ 提交于 2019-12-18 15:56:44

C99中支持bool,是以宏定义实现

//
// stdbool.h
//
//      Copyright (c) Microsoft Corporation. All rights reserved.
//
// The C Standard Library <stdbool.h> header.
//
#ifndef _STDBOOL
#define _STDBOOL

#define __bool_true_false_are_defined   1

#ifndef __cplusplus

#define bool    _Bool
#define false   0
#define true    1

#endif /* __cplusplus */

#endif /* _STDBOOL */

 

可以自定义bool类型,就不会涉及bool型转int型的问题

#ifndef __cplusplus
#ifndef bool
#define bool     int
#define true     1
#define false    0
#endif
#endif

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!