解决MySQL的C++驱动报错:‘my_bool’ was not declared in this scope; did you mean ‘bool’?
解决MySQL的C++驱动报错:‘my_bool’ was not declared in this scope; did you mean ‘bool’?
问题描述
此问题仅影响 MySQL; MariaDB将继续支持。
尝试使用 MySQL 8.0.1 进行编译时发生以下构建错误,无法识别 m_bool
类型:
motion.c: In function ‘motion_init’:
motion.c:1146:13: error: unknown type name ‘my_bool’; did you mean ‘bool’?
1146 | my_bool my_true = TRUE;
| ^~~~~~~
| bool
make: *** [Makefile:105: motion.o] Error 1
make: *** Waiting for unfinished jobs....
解决方法
在MySQL :: MySQL 8.0 Release Notes :: Changes in MySQL 8.0.1 (2017-04-10, Development Milestone)中注明:mysql.h 头文件现在需要 C++ 或 C99 编译器才能编译。MySQL源代码中不再使用该类型。使用此类型来表示 C 布尔变量的任何第三方代码都应改用 bool
或 int C 类型。