我正在使用 Code::Blocks 将 Python(包含 Mosquitto MQTT)脚本重写为 C。作为测试,我使用了 Mosquitto 存储库中可用的以下代码:
但是,这会导致以下警告:
||=== Build: Debug in test (compiler: GNU GCC Compiler) ===|
..\..\..\..\..\Program Files (x86)\mosquitto\devel\mosquitto.h|56|warning: "bool" redefined|
c:\mingw32-xy\bin\..\lib\gcc\mingw32\4.5.2\include\stdbool.h|33|note: this is the location of the previous definition|
obj\Debug\main.o||In function `on_connect':|
我一直在深入研究这个主题,我认为可以使用包含警卫来解决它。我做了一些测试,但显然我不知道如何正确应用它们。
由于我不是经验丰富的 C 程序员,我决定寻求帮助。
编辑:我添加了mosquitto.h 代码的链接。
这是可能出错的部分:
#ifndef _MOSQUITTO_H_
#define _MOSQUITTO_H_
#ifdef __cplusplus
extern "C" {
#endif
#if defined(WIN32) && !defined(WITH_BROKER)
# ifdef libmosquitto_EXPORTS
# define libmosq_EXPORT __declspec(dllexport)
# else
# define libmosq_EXPORT __declspec(dllimport)
# endif
#else
# define libmosq_EXPORT
#endif
#ifdef WIN32
# ifndef __cplusplus
# define bool char
# define true 1
# define false 0
# endif
#else
# ifndef __cplusplus
# include <stdbool.h>
# endif
#endif
是否有快速修复使其工作?