您可以将返回值解释为布尔值(并将值作为布尔值传递给 gpio 读取和写入,只要您在 C 中编译您的项目,但一旦尝试在 C++ 中编译,它们与布尔值不兼容但返回 GPIO_PIN_SET 或 GPIO_PIN_RESET 不兼容由编译器解释为布尔值。
这是编译端还是 HAL 库端的问题?
注意:屏幕截图将错误显示为 int 而不是布尔值。我导入了 stbool :
- #ifndef __cplusplus
- #define bool _Bool
- #define true 1
- #define false 0
- #else /* __cplusplus */
- /* Supporting _Bool in C++ is a GCC extension. */
- #define _Bool bool
- #if __cplusplus < 201103L
- /* Defining these macros in C++98 is a GCC extension. */
- #define bool bool
- #define false false
- #define true true
- #endif
- #endif /* __cplusplus */
注意:按照编译器消息的建议,通过将 -fpermissive 添加到我的标志编译器来部分解决此问题。
谢谢你的帮助。