小编L C*_* Co的帖子

我可以模仿在C++中重新定义bool的C头吗?

我正在编写一个程序,我更喜欢用C++编写,但是,我需要包含一个重新定义bool的C头:

# define false 0
# define true  1
typedef int bool;
Run Code Online (Sandbox Code Playgroud)

显而易见的解决方案是编辑标题来说:

#ifndef __cplusplus
# define false 0
# define true  1
typedef int bool;
#endif
Run Code Online (Sandbox Code Playgroud)

但是,唉,因为图书馆是只读的我不能.

有没有办法告诉gcc忽略这个typedef?或者,我可以用C++编写大多数函数,然后为这两个函数创建一个C包装器吗?或者,我应该把它吸干并用C写出来吗?

c c++ typedef mixing

55
推荐指数
5
解决办法
3311
查看次数

标签 统计

c ×1

c++ ×1

mixing ×1

typedef ×1