hirotakaster / MQTT

MQTT for Photon, Spark Core
Other
217 stars 118 forks source link

Include header guards in MQTT.h #51

Closed alignan closed 7 years ago

alignan commented 7 years ago

To avoid errors like error: previous definition of 'class MQTT'

hirotakaster commented 7 years ago

I don't know what's happen on only this error line.

ScruffR commented 7 years ago

@hirotakaster, the common practice for all headers should be to guard against multiple inclusion. This is either done as

#ifndef _YOUR_LIBRARY_H_
#define _YOUR_LIBRARY_H_
// here follows the code
#endif

or via

#pragma once
// here follows your code
hirotakaster commented 7 years ago

Hi @ScruffR I add ifdef to header file, but I can't use MQTT my lib on WebIDE and local Particle Dev!! compile message is "MQTT.h: No such file or directory".

#include <MQTT.h>
#include "MQTT.h"
#include "MQTT/MQTT.h"

all patter is fail "MQTT.h: No such file or directory" now. I don't know why this happen, but I think Particle community lib is broken now.

ScruffR commented 7 years ago

That is due to an issue on the Particle side. https://github.com/spark/particle-dev-libraries/issues/26

You need to remove the nested MQTT folder with the header stubs (on your local copy of the lib, not on the published version).

hirotakaster commented 7 years ago

@ScruffR Okay, thank you. I can compile on "Particle Dev" local pc. But still can't compile on WebIDE.