Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Visual Studio

Thanks Mark. It has come up before but I need to fix it. My preferred way is:

#define MQTTClient_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, NULL, NULL, 0, 0 }

The compilation methods I usually use don't complain.  I'll fix it.

Ian

On 24/02/13 13:34, Cullen, Mark wrote:
Hello

I'm new to the list so sorry if this has come up before.

I am trying to use the Paho C client in Windows using Visual Studio 2005

I came across a problem while trying to compile the async publish example.

These to lines

MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
MQTTClient_message pubmsg = MQTTClient_message_initializer;

cause

error C2117: 'MQTTClient_connectOptions::struct_id' : array bounds overflow

The problem is the initializers contain strings like "MQTM" these are actually 5 characters long (0 terminator), but the structure definitions contain char struct_id[4]; which is only 4.

For Visual Studio changing

#define MQTTClient_willOptions_initializer { "MQTW", 0, NULL, NULL, 0, 0 }
to

#define MQTTClient_willOptions_initializer { 'M', 'Q', 'T', 'W', 0, NULL, NULL, 0, 0 }

But I don't know if this will work with other compilers like GCC etc


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/paho-dev




Back to the top