Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Compiling C++ client

Hey Roger,

BTW, if you peek under the hood of the C++ wrapper, please let me know what you think. After being totally swamped for the better part of a year, I've finally freed up my schedule to get this into a release worthy-state. I will be concentrating on some MQTT/Paho stuff the next few weeks.

I have a few updates already. A few months back the C library added better tracking of the message token/ID from the async library, so that makes the job of a wrapper much easier. So the next update will be a little simpler with not so much locking.

I also started working on a wrapper for the "D" language. An interesting aspect of that one is the ability of the language to promise immutability of the messages - or at least individually for the payloads and topic strings. That significantly reduces the amount of locking and copying that needs to be done, and the number of race conditions that you need to fret over. If everyone promises not to change the message, then you don't need to copy it or keep protecting it for exclusive access,

I'm wondering if it wouldn't be nice to try something like that in the C++ library. It could be as "simple" as making the shared pointers const. That might have a ripple effect, but might make the library simpler and more efficient.

Frank

On 05/19/2015 03:57 AM, Roger Light wrote:
Hi Frank,

Thanks, that does the job.

Cheers,

Roger


On Tue, May 19, 2015 at 3:24 AM, Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx> wrote:
Hey Roger,

I'll upload a fix when I get a minute, but it seems that the C API changed (for the better) and broke the C++ wrapper.

The clientID and serverURI parameters of iclient_persistence::persistence_open() should now be "const char*" instead of "char*"

Frank

------------

diff --git a/src/iclient_persistence.cpp b/src/iclient_persistence.cpp
index 755c561..32f617e 100644
--- a/src/iclient_persistence.cpp
+++ b/src/iclient_persistence.cpp
@@ -70,8 +70,8 @@ public:
 // C++ persistence object, which is reassigned to the 'handle'. Subsequent
 // calls have the object address as the handle.
 
-int iclient_persistence::persistence_open(void** handle, char* clientID,
-                                                                                 char* serverURI, void* context)
+int iclient_persistence::persistence_open(void** handle, const char* clientID,
+                                                                                 const char* serverURI, void* context)
 {
        try {
                if (context) {
diff --git a/src/mqtt/iclient_persistence.h b/src/mqtt/iclient_persistence.h
index 1fad4df..f44dd9a 100644
--- a/src/mqtt/iclient_persistence.h
+++ b/src/mqtt/iclient_persistence.h
@@ -61,7 +61,7 @@ class iclient_persistence
 public:
 
        /** C-callbacks  */
-       static int persistence_open(void** handle, char* clientID, char* serverURI, void* context);
+       static int persistence_open(void** handle, const char* clientID, const char* serverURI, void* context);
        static int persistence_close(void* handle);
        static int persistence_put(void* handle, char* key, int bufcount, char* buffers[], int buflens[]);
        static int persistence_get(void* handle, char* key, char** buffer, int* buflen);



On 05/18/2015 05:46 PM, Roger Light wrote:
Hi Frank,

Linux and g++ 4.6, 4.9 and 5.0.

Cheers,

Roger


On Mon, May 18, 2015 at 7:29 PM, Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx> wrote:
I'll have a look. I've been sitting on an update for a while now, and haven't checked the current code against the latest C library (which it wraps).

What host / OS / compiler / version(s) are you trying this with?

Frank


On 05/18/2015 02:23 PM, Roger Light wrote:
Hi,

I'm having problems compiling the C++ library, can anybody assist?

I've done:

export PAHO_C_LIB=<path to Paho C repo>
cd src
make -f ../Makefile

The error I get is:

async_client.cpp: In constructor ‘mqtt::async_client::async_client(const string&, const string&, mqtt::iclient_persistence*)’:
async_client.cpp:76:3: error: could not convert ‘{persistence, mqtt::iclient_persistence::persistence_open, mqtt::iclient_persistence::persistence_close, mqtt::iclient_persistence::persistence_put, mqtt::iclient_persistence::persistence_get, mqtt::iclient_persistence::persistence_remove, mqtt::iclient_persistence::persistence_keys, mqtt::iclient_persistence::persistence_clear, mqtt::iclient_persistence::persistence_containskey}’ from ‘<brace-enclosed initializer list>’ to ‘MQTTClient_persistence’
   };
   ^
make: *** [obj/async_client.o] Error 1

Cheers,

Roger



_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev



_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev



_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev


Back to the top