Check if bool is defined in mixed C/C++

前端 未结 4 917
甜味超标
甜味超标 2021-02-05 19:51

So I\'m having issues with some code that I\'ve inherited. This code was building fine in a C-only environment, but now I need to use C++ to call this code. The header p

4条回答
  •  故里飘歌
    2021-02-05 20:36

    Because bool is a basic type in C++ (but not in C), and can't be redefined.

    You can surround your code with

    #ifndef __cplusplus
    typedef unsigned char bool;
    static const bool False = 0;
    static const bool True = 1;
    #endif
    

提交回复
热议问题