Azure / azure-sdk-for-cpp

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our versioned developer docs at https://azure.github.io/azure-sdk-for-cpp.
MIT License
170 stars 118 forks source link

Telemetry policy to send what C++ language version is used when customers are building with our SDK #5661

Open antkmsft opened 1 month ago

antkmsft commented 1 month ago

It can be done, if the __cplusplus would be expanded in .hpp, NOT in .cpp - that would show the value of the macro when our sdk is consumed, not when it is built.

That could happen in the private constructor for the telemetry policy.

Illustration: https://godbolt.org/z/5d8P7qq89 (try modifying the value of -std=c++17)

#include <iostream>

// AzureSDK.hpp
namespace Azure {
namespace _internal {
    void UseAzureSDKInternal(long cppver);
}
    void UseAzureSDK() { _internal::UseAzureSDKInternal(__cplusplus); }
}

// AzureSDK.cpp
//#include <AzureSDK.hpp>
void Azure::_internal::UseAzureSDKInternal(long cppver)
{
    std::cout << cppver;
}

// Customer's code:
//#include <AzureSDK.hpp>
int main ()
{
    Azure::UseAzureSDK();
}
github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.