C doesn't have a bool? Also VS2010 question

前端 未结 6 1823
礼貌的吻别
礼貌的吻别 2021-01-12 16:17

I\'m using VS 2010 Pro.

First, C doesn\'t have a bool type? I just have to use int with 0/1. Seems odd as most languages consider boolean a standard type.

6条回答
  •  伪装坚强ぢ
    2021-01-12 17:03

    If you're developing in C, I'd recommend a different compiler as VC++ is not a modern C compilier and does not support the C99 standard. If you're on windows try MinGW, which basically gets you GCC with access to Windows-y API stuff.

    If you're set on using Visual Studio, create your own header file to use instead of stdbool.h:

    #pragma once
    
    #define false   0
    #define true    1
    
    #define bool int
    

    I found that Visual Studio 2010 complained if I tried to use a typedef instead of a #define to define bool.

提交回复
热议问题