Connect to Azure IoT Hub invalid operands of types 'char*' and 'char*' to binary

Hello,

I'm trying to send sensor data to Azure IoT Hub using the Dave's Glover solution "Securely stream data from ESP8266 MCUs to Azure IoT Hub or Azure IoT Central" - GitHub - gloveboxes/Arduino-ESP8266-Secure-Http-Azure-IoT-Hub-Client-V2

I see it works for most people, but I'm running in an compilation error for a concatenation chain"

SasToken.cpp:50:14: error: invalid operands of types 'char*' and 'char*' to binary 'operator+'

sasPointer += snprintf(sasPointer, sizeof(sas.token), "SharedAccessSignature sr=%s/devices/%s&sig=", this->device.host, this->device.id);

^

SasToken.cpp:50:14: error: in evaluation of 'operator+=(char*, char*)'

Can you help me out here?
Thanks

SasToken.cpp (2.86 KB)

You defined "snprintf" as an empty macro. What did you expect it to do?

It'll just cause the preprocessor to remove it altogether, converting the line

sasPointer += snprintf(sasPointer, sizeof(sas.token), "SharedAccessSignature sr=%s/devices/%s&sig=", this->device.host, this->device.id);

to

sasPointer += (sasPointer, sizeof(sas.token), "SharedAccessSignature sr=%s/devices/%s&sig=", this->device.host, this->device.id);

After removing the parentheses and evaluating the comma operators, this effectively becomes

sasPointer += this->device.id;

which is meaningless of course, resulting in an error telling you that you cannot add to char pointers.

Remove the macro, include the correct header file that declares the "snprintf" function.

Pieter