ST意法半导体
直播中

母猪会上树

11年用户 908经验值
擅长:电源/新能源
私信 关注
[问答]

GPIO_PIN_RESET与C++编译器不兼容是什么原因导致的

您可以将返回值解释为布尔值(并将值作为布尔值传递给 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 添加到我的标志编译器来部分解决此问题。
谢谢你的帮助。




回帖(1)

黄璨

2022-12-19 11:50:16
我只是指出这个错误在 C 中不存在,并且在我用 C++ 编译我的项目时立即出现。所以这可能会让一些人感到不安。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分