Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
585 stars 739 forks source link

Undefined references from iothub_client_properties.h when included in C++ source file #2540

Closed D-r-P-3-p-p-3-r closed 8 months ago

D-r-P-3-p-p-3-r commented 9 months ago

I got messages from the linker like

undefined reference to `IoTHubClient_Properties_Serializer_CreateReported(IOTHUB_CLIENT_PROPERTY_REPORTED_TAG const, unsigned int, char const, unsigned char*, unsigned int)

undefined reference to `IoTHubClient_Properties_Serializer_Destroy(unsigned char*)'

when including _iothub_clientproperties.h in a C++ source code file.

The problem is that _iothub_clientproperties.h does not contain an extern "C" specification like

#ifdef __cplusplus
extern "C"
{
#endif

// ...

#ifdef __cplusplus
}
#endif

Including the file via

extern "C" {
#include <iothub_client_properties.h>
}

works but is ugly like hell.

CIPop commented 9 months ago

Thanks @D-r-P-3-p-p-3-r for your report. Please feel free to submit a PR.

ericwolz commented 8 months ago

2548

ericwolz commented 8 months ago

resolved