Azure-iot-sdk-c: Compile error with downloaded code

Created on 7 Jan 2019  Â·  24Comments  Â·  Source: Azure/azure-iot-sdk-c

Please first tell us a little bit about the environment you're running:
-->

  • OS and version used: Windows 10 64 bit 1709 release 16299.846-->

  • SDK version used: Arduino IDE 1.8.7-->

Description of the issue:

I am receiving a compile error when I try to compile the code from the URL:
https://azure.microsoft.com/en-us/resources/samples/iot-hub-c-thingdev-getstartedkit/

I searched the Issues listed, and I did not seem to find an issue reported for this already. Katrien De Graeve suggested I post this issue here.

Please note that in researching this error, I found multiple others who were looking for help with this same error in since the beginning of December. Looks like something changed recently that is affecting the code to compile.

All code is directly from the URL and has not been modified. All libraries are either downloaded with the URL or, if not available, from the Auduino Library Manager.

Compile Error is below.

In file included from C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTUtility-1.0.45\src/azure_c_shared_utility/lock.h:17:0,

             from C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTUtility-1.0.45\src/AzureIoTUtility.h:7,

             from C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTHub-1.0.45\src/AzureIoTHub.h:7,

             from sketch\remote_monitoring.c:7:

C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTHub-1.0.45\src/sdk/serializer.h:441:79: error: 'REFLECTED_39' undeclared here (not in a function)

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                           ^

C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTUtility-1.0.45\src/azure_c_shared_utility/macro_utils.h:4359:18: note: in definition of macro 'C2_'

define C2_(x,y) x##y

              ^

C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTHub-1.0.45\src/sdk/serializer.h:441:76: note: in expansion of macro 'C2'

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                        ^

C:\Users\pkimbell\OneDrive - Clariant\Documents\Arduino\libraries\AzureIoTHub-1.0.45\src/sdk/serializer.h:87:5: note: in expansion of macro 'REFLECTED_LIST_HEAD'

 REFLECTED_LIST_HEAD(schemaNamespace)

 ^

sketch\remote_monitoring.c:51:1: note: in expansion of macro 'END_NAMESPACE'

END_NAMESPACE(Contoso);

^

exit status 1
Error compiling for board SparkFun ESP8266 Thing Dev.

Code sample exhibiting the issue:

See code in the URL mentioned

Console log of the issue:

No Logs are availabe since error is from compiling the code.

arduino bug

Most helpful comment

@YoDaMa, @pkimbell ,

I tried to get the sketch working too but run into these issues:

In file included from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/WiFiClient.h:25:0,
from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39,
from C:\Users\sande\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.cpp:9:

c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::poisson_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::binomial_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

exit status 1
Error compiling for board SparkFun ESP8266 Thing Dev.

I would like to see NodeMCU support for Azure IoT re-established too.

All 24 comments

hi @pkimbell we haven't updated the arduino libraries in a while which is likely related to the issue. In the next days we should be updating our process of publishing arduino libraries so they stay more up to date. I'll keep you updated on this.

I'm trying to compile on a Mac and getting the same error.

I am getting the same error as well none of the examples for 8266 seem to be working. Both windows and Mac

I am getting the same error. Is it any progress? Thank you.

We are also having exactly the same issue. Please help us out here.
Thanks in advance.

Same Error here.

Also getting the same error — is there a workaround with rolling back library versions at all?

Just an update, we are actively working on fixing the Arduino SDK libraries.

The progress on updating the published Arduino libraries of the code is currently blocked as we fix some core problems with previous versions of the published Arduino SDK Libraries. Since the previous versions did not authenticate the connection by exchanging and validating trusted certs to IoT Hub, we are fixing this in the code before moving forward with releasing another version of the libraries.

In the meantime, to tinker with the latest version of the SDK using Arduino Libraries, you can manually build the libraries locally. This will not fix the sample, just bump the version of the SDK.

How to manually build the library locally:
This is using the same process that generates libraries that do not support trusted certs, which means that your devices could be connecting to any spoofed connection point and not validating that it's the actual IoT Hub. SO DO NOT USE THIS CODE IN PRODUCTION DEVICES. Only use the manual process for tinkering (as a community also we are happy have you look into some of the library versioning issues, particularly in ESP8266).

Steps to manually create local versions of Arduino Libraries:

Clone the PAL Repo (you need recursive because the C SDK is included as a submodule):

git clone --recursive https://github.com/Azure/azure-iot-pal-arduino.git 

Navigate to the build_all directory:

cd build_all

Run make_sdk.cmd, specifying the location of the Arduino Library on your machine:

.\make_sdk.cmd C:\Users\<username>\Documents\Arduino\libraries

This'll populate the Arduino libraries with the 4 AzureIoT Libraries using the latest SDK.

I followed this procedure, but still have the same compilation error. I'm trying to run this sample https://github.com/Azure/azure-iot-arduino/issues/86

I followed this procedure, but still have the same compilation error. I'm trying to run this sample Azure/azure-iot-arduino#86

the steps do not provide a fix for the sample. The sample is using some old serializer.h code. As a SDK we're trying to shift away from serializer.h, so we're going to clean up documentation and our online samples. It's noted at the top of the referenced repo that the sample is no longer updated... but I empathize that we've left some samples online and people are still seeking to use this sample in particular.

You should be able now to run the Feather Huzzah Sample, only just specify the ESP8266 Thing Dev Board. There is one issue with the ESP8266 Library that can be solved following the instructions in Github Issue #877

Hi @YoDaMa any updates on this issue I am getting the same error as was raised in the issue. After following your method of manually build the libraries I found no change in the situation, but a few more re-directions were added onto the list

`
In file included from C:\Users\\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/umock_c_prod.h:23:0,
from C:\Users\\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/strings.h:7,

             from C:\Users\<username>\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/platform.h:7,

             from C:\Users\<username>\Documents\Arduino\libraries\AzureIoTUtility\src/AzureIoTUtility.h:7,

             from C:\Users\<username>\Documents\Arduino\libraries\AzureIoTHub\src/AzureIoTHub.h:7,

             from C:\Users\<username>\AppData\Local\Temp\arduino_build_550041\sketch\simplesample_mqtt.c:9:

C:\Users\\Documents\Arduino\libraries\AzureIoTHub\src/serializer.h:441:80: error: 'REFLECTED_19' undeclared here (not in a function)
`

Hi @pkimbell ,
I am helping investigate this issue with @YoDaMa .
Yes, we were able to get to the point of reproducing both issues:

  • The name conflic;

    This is root-caused, and we are working on rolling out the fix.

  • The macro evaluation failure;

    The serializer code has many macro definitions, and it is failing during pre-compilation on Arduino platforms. We are still working on this one.

I really look forward for a fix from @pkimbell and @YoDaMa

@YoDaMa, @pkimbell ,

I tried to get the sketch working too but run into these issues:

In file included from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/WiFiClient.h:25:0,
from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39,
from C:\Users\sande\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.cpp:9:

c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::poisson_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::binomial_distribution<_IntType>::param_type::_M_initialize()':

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
^

exit status 1
Error compiling for board SparkFun ESP8266 Thing Dev.

I would like to see NodeMCU support for Azure IoT re-established too.

hi @YoDaMa and ewertons,
i am having same issue.please let us know how to solve it.
In file included from C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/optionhandler.h:7:0,

             from C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/xio.h:7,

             from C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/platform.h:11,

             from C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTUtility\src/AzureIoTUtility.h:7,

             from C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTHub\src/AzureIoTHub.h:7,

             from sketch\simplesample_mqtt.c:9:

C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:441:79: error: 'REFLECTED_19' undeclared here (not in a function)

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                           ^

C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/macro_utils.h:4355:18: note: in definition of macro 'C2_'

#define C2_(x,y) x##y

              ^

C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:441:76: note: in expansion of macro 'C2'

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                        ^

C:\Users\krish\OneDrive\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:87:5: note: in expansion of macro 'REFLECTED_LIST_HEAD'

 REFLECTED_LIST_HEAD(schemaNamespace)

 ^

sketch\simplesample_mqtt.c:30:1: note: in expansion of macro 'END_NAMESPACE'

END_NAMESPACE(WeatherStation);

^

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Is there an ETA for resolving this issue? I am having the same problem:

Build options changed, rebuilding all
In file included from C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/lock.h:17:0,

             from C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTUtility\src/AzureIoTUtility.h:7,

             from C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTHub\src/AzureIoTHub.h:7,

             from sketch\simplesample_http.c:15:

C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:441:79: error: 'REFLECTED_15' undeclared here (not in a function)

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                           ^

C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTUtility\src/azure_c_shared_utility/macro_utils.h:4359:18: note: in definition of macro 'C2_'

#define C2_(x,y) x##y

              ^

C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:441:76: note: in expansion of macro 'C2'

 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };

                                                                        ^

C:\Users\dexterm\Documents\Arduino\libraries\AzureIoTHub\src/sdk/serializer.h:87:5: note: in expansion of macro 'REFLECTED_LIST_HEAD'

 REFLECTED_LIST_HEAD(schemaNamespace)

 ^

sketch\simplesample_http.c:43:1: note: in expansion of macro 'END_NAMESPACE'

END_NAMESPACE(WeatherStation);

^

exit status 1

I had the same issues and finally got a working setup by installing certain specific versions. Others pointed out that they got it working by rollback to an older version, but I could not find a working set of compatible versions anywhere. Please always mention the specific version as this may help others reading your messages!
I hope it helps others when I explain what I did.

At first, installing different version of the esp8266 board and the AzureIoT libraries did not help me. I was getting the same "sort of" compile errors. So then I decided to remove all the installed versions from disk. First close Arduino IDE, and then remove the folders (paths for MacOS):

  • ~/Library/Arduino15/packages (the board)
  • ~/Documents/Arduino/libraries (the libraries)

Finally install the exactly the following versions.
Board:

  • esp8266 (by ESP8266 community) - 2.4.2

Libraries:

  • Azureiothub - 1.0.45
  • Azureiotprotocol_mqtt - 1.0.45
  • azureiotutility - 1.0.45

I don't think the problems would relate to a specific version of the Arduino IDE, but to make it complete, this was all done in Arduino IDE v1.8.10.

To prove that the complete solution worked I used this guide to read data from Azure IoT hub which was sent by the ESP8266: https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-node#code-try-2

At first, installing different version of the esp8266 board and the AzureIoT libraries did not help me. I was getting the same "sort of" compile errors. So then I decided to remove all the installed version from disk. First close Arduino IDE, and then remove the folders (paths for MacOS):

  • ~/Library/Arduino15/packages (the board)
  • ~/Documents/Arduino/libraries (the libraries)

On Windows, it could be respectively C:\Users\(username)\AppData\Local\Arduino15 and My Documents\Arduino\libraries.
On Linux it could be respectively ~/.arduino15 and ~/Arduino/ .
But I haven't verified this! See also: https://www.arduino.cc/en/hacking/libraries

I had the same issues and finally got a working setup by installing certain specific versions. Others pointed out that they got it working by rollback to an older version, but I could not find a working set of compatible versions anywhere. Please always mention the specific version as this may help others reading your messages!
I hope it helps others when I explain what I did.

At first, installing different version of the esp8266 board and the AzureIoT libraries did not help me. I was getting the same "sort of" compile errors. So then I decided to remove all the installed versions from disk. First close Arduino IDE, and then remove the folders (paths for MacOS):

  • ~/Library/Arduino15/packages (the board)
  • ~/Documents/Arduino/libraries (the libraries)

Finally install the exactly the following versions.
Board:

  • esp8266 (by ESP8266 community) - 2.4.2

Libraries:

  • Azureiothub - 1.0.45
  • Azureiotprotocol_mqtt - 1.0.45
  • azureiotutility - 1.0.45

I don't think the problems would relate to a specific version of the Arduino IDE, but to make it complete, this was all done in Arduino IDE v1.8.10.

To prove that the complete solution worked I used this guide to read data from Azure IoT hub which was sent by the ESP8266: https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-node#code-try-2

Key for me was rolling back esp8266 (by ESP8266 community) to version 2.4.2! Thanks!

@YoDaMa, @pkimbell ,
I tried to get the sketch working too but run into these issues:

In file included from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/WiFiClient.h:25:0,
from C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:39,
from C:\Users\sande\Documents\Arduino\libraries\AzureIoTUtility\src\adapters\sslClient_arduino.cpp:9:
c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::poisson_distribution<_IntType>::param_type::_M_initialize()':
C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

^
c:users\sande\appdata\local\arduino15\packages\esp8266\toolsxtensa-lx106-elf-gcc\2.5.0-3-20ed2b9xtensa-lx106-elf\include\c++\4.8.2\bits\random.tcc: In member function 'void std::binomial_distribution<_IntType>::param_type::_M_initialize()':
C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

^
C:\Users\sande\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/Arduino.h:137:22: error: expected unqualified-id before '(' token

define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

^
exit status 1
Error compiling for board SparkFun ESP8266 Thing Dev.

I can comment on this particular issue with the #define round, there is actually an issue closed on the esp Arduino repo (https://github.com/esp8266/Arduino/issues/5787) where a developer states that they will not be fixing this at this time. The current solution for this define round bug is to manually comment it out in esp8266's Arduino.h file.

Thank you for reporting this issue, please follow the guidance provided by @jbobotek.

@pkimbell, @YoDaMa, @ob1juan, @arnold256, @mata80, @AdarshanaBlr, @HITliuyu, @benparsell, @Dan-cws, @mysaggar, @ewertons, @janneumann, @sandervandevelde, @saikrishnachoppa, @d-e-m, @rachidbm, @Dewieinns, @jbobotek, @gregman-msft, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wlisac picture wlisac  Â·  4Comments

caobaokun picture caobaokun  Â·  7Comments

alexeystrakh picture alexeystrakh  Â·  5Comments

moncef-bibani picture moncef-bibani  Â·  4Comments

duvitech picture duvitech  Â·  6Comments