今日は、新たな発見がありました。
stdbool.hの中で定義されているbool型用のtrue,falseについてです。stdbool.hには下記ようのに定義されています。
stdbool.h
# ifndef __cplusplus
# define bool _Bool
# define true 1
# define false 0
# else /* __cplusplus */
以下省略
c言語で利用する場合は、__cplusplusが定義されていないので、true,falseはint型です。下のように書いても問題ないはず。
sample.c
# include <stdio.h>
# include <stdbool.h>
static int s_value = 0;
void func(bool state )
{
s_value = state;
}
int main( int argc, char *argv[] )
{
func(false);
printf("value=%d\n", s_value);
return 0;
}