azure-sdk-for-cpp icon indicating copy to clipboard operation
azure-sdk-for-cpp copied to clipboard

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

Open antkmsft opened this issue 1 year ago • 1 comments

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();
}

antkmsft avatar May 23 '24 19:05 antkmsft

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

github-actions[bot] avatar May 23 '24 19:05 github-actions[bot]