Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC RFC] header only API for singletons (Windows) #1595

Closed
3 changes: 2 additions & 1 deletion api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
#elif defined(__GNUC__)
# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default")))
#elif defined(_MSC_VER)
# define OPENTELEMETRY_API_SINGLETON
/* Tentative fix */
# define OPENTELEMETRY_API_SINGLETON __declspec(selectany)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why __declspec(selectany) is removed?Doesn't it work with MSVC on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owent

__declspec(selectany) works when applied to a member.

This PR tested applying it to a method, which failed to compile.

See places where OPENTELEMETRY_API_SINGLETON is used in this patch,
which are different compared to PR#1525

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add __declspec(selectany) to variables, so we can also support dll on Windows with MSVC?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@owent, see file macros.h in the latest push.

#else
# define OPENTELEMETRY_API_SINGLETON
#endif