eclipse / paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)

Home Page:https://eclipse.org/paho

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Result enum is too common

MikhailNatalenko opened this issue · comments

Hello!
I am trying to compile MQTTClient with stm32 HAL, and I have problems with enum redeclaration

enum returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESS = 0 };

Isn't SUCCESS word too common? Anyway I have problems with it and there is a big chance to redeclare it for someone else. I understand, that it's almost impossible to fix it without loss of support. How can I workaround this problem? I don't want to make fixes in stable libraries.

Fixing this would indeed be a breaking API change for existing clients.
I will be considering these issues for MQTTv5 clients.

I looked closer and realized that returnCode is not actually a required part of the API.
These values are returned by the code but the return types of the functions are not actually returnCode. Given that apps used the values in the past, one could argue that modifying them is still a breaking change.

I still recommend we take the change but I would separate it from the V5 work.

In the main C client, I prefixed all constants with either MQTTCLIENT_ or MQTTASYNC_, and the V5 reason codes with MQTTREASONCODE_

I'm not saying those are the best choices, but we could use the same convention for the sake of making the APIs similar.

The other thought I had was to prefix them all with PAHO_ to distinguish between other APIs. But I would advocate following the main C client API convention, unless there's a specific objection, to get more of a family feel.

If we're going for a significant renaming exercise, which I think we should for these enums/constants, then we'll need a major version change to signify that (2.0.0).