Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public API: avoid name collisions #243

Merged
merged 3 commits into from
Aug 1, 2023
Merged

Conversation

CIPop
Copy link

@CIPop CIPop commented Jul 25, 2023

Repurposing to include fix for #180:

  • Renaming struct and enums to avoid name collisions in existing code for MQTTClient-C and MQTTPacket/V5. The C++ client uses namespaces and should be ok.
  • Disabling test-code deprecation warnings (CMake full build has no warnings).

This is a public API breaking change which will result in a major version release.

@CIPop
Copy link
Author

CIPop commented Jul 25, 2023

Error when trying to build a new MQTTV5Client:

FAILED: MQTTClient-C/src/CMakeFiles/paho-embed-mqtt5cc.dir/MQTTClient.c.o 
/usr/bin/cc -DMQTTCLIENT_PLATFORM_HEADER=MQTTLinux.h -DMQTTCLIENT_QOS2=1 -DMQTTV5 -Dpaho_embed_mqtt5cc_EXPORTS -I/home/crispop/paho.mqtt.embedded-c/MQTTPacket/src -I/home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/linux -g -fPIC -MD -MT MQTTClient-C/src/CMakeFiles/paho-embed-mqtt5cc.dir/MQTTClient.c.o -MF MQTTClient-C/src/CMakeFiles/paho-embed-mqtt5cc.dir/MQTTClient.c.o.d -o MQTTClient-C/src/CMakeFiles/paho-embed-mqtt5cc.dir/MQTTClient.c.o -c /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/MQTTClient.c
In file included from /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/V5/MQTTV5Client.h:22,
                 from /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/MQTTClient.c:19:
/home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/V5/../MQTTClient.h:61:55: error: redeclaration of enumerator ‘SUCCESS’
   61 | enum returnCode { BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESS = 0 };
      |                                                       ^~~~~~~
In file included from /home/crispop/paho.mqtt.embedded-c/MQTTPacket/src/V5/MQTTV5Packet.h:26,
                 from /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/V5/../MQTTClient.h:38,
                 from /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/V5/MQTTV5Client.h:22,
                 from /home/crispop/paho.mqtt.embedded-c/MQTTClient-C/src/MQTTClient.c:19:
/home/crispop/paho.mqtt.embedded-c/MQTTPacket/src/V5/MQTTReasonCodes.h:18:3: note: previous definition of ‘SUCCESS’ was here
   18 |   SUCCESS = 0,
      |   ^~~~~~~

@icraggs icraggs linked an issue Jul 27, 2023 that may be closed by this pull request
@icraggs
Copy link
Contributor

icraggs commented Jul 27, 2023

I had put my comments in #180:

n 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).

@icraggs
Copy link
Contributor

icraggs commented Jul 27, 2023

I've recreated the mqttv5 branch and updated it match develop, so we can use that as a working branch for a V5 MQTTClient layer

@CIPop
Copy link
Author

CIPop commented Jul 27, 2023

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).

I agree as well:

  1. MQTTClient-C will follow Paho Main.
  2. It's a good idea to change all of them now.
  3. I will also propose a separate PR with changes to the file-names to differentiate between MQTTClient for C, MQTTClient for C++, etc.

I can re-use this PR to make all changes towards develop.

I've recreated the mqttv5 branch and updated it match develop, so we can use that as a working branch for a V5 MQTTClient layer

Thank you! I will start submitting partial work, starting with the MQTTV5Client-C API surface PR there.

@CIPop CIPop marked this pull request as draft July 27, 2023 20:32
@CIPop CIPop changed the title Public API change: V5 reason code renaming Public API: avoid name collisions Jul 27, 2023
@CIPop
Copy link
Author

CIPop commented Jul 28, 2023

@icraggs PTAL - I've included many other changes (unfortunately this might have brought the line-count > 1k)
A future PR should change the file-names to disambiguate between the C++ and C clients.

@CIPop
Copy link
Author

CIPop commented Jul 28, 2023

@MikhailNatalenko please let me know if this addresses all your concerns from #180.

Copy link
Contributor

@icraggs icraggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Gets us closer to where we want to be. Under the 1000 lines too.

@CIPop CIPop marked this pull request as ready for review July 28, 2023 16:56
@CIPop
Copy link
Author

CIPop commented Jul 28, 2023

Rebased on top of develop. ctest passed locally.

@icraggs icraggs merged commit 0792363 into eclipse:develop Aug 1, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Result enum is too common
2 participants