-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
The current way of getting unstable declarations available only in statically-linked code is to set a macro and then include zstd. But this is clumsy for users in larger projects. For example, including one header that includes the zstd header, then including another header that includes the zstd header with unstable declarations, won't work. Effectively, including zstd unstable declarations from a library header is broken. As a workaround, it is often the case that libraries could wrap up the zstd unstable declarations in their own wrappers and only include zstd from a source file owned by the library. But this would not be acceptable for header-only C++ libraries.
An alternative would be to have a separate header for these declarations. Rather than setting a macro and then including zstd, users would just include zstd-static.
This could be done compatibly, where users could do either one at will. Effectively:
// zstd.h
#pragma once
#if ZSTD_STATIC_LINKING_ONLY
#include <zstd/unstable.h>
#endif
// ...
This would not break existing code and the current pattern of setting the macro before including zstd could still be encouraged. But library headers could get an alternative which is not broken.