microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
include
microfmt
microfmt_extern.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Jarosław Pelczar <jarek@jpelczar.com>
2
//
3
// SPDX-License-Identifier: BSD-2-Clause
4
5
#pragma once
6
63
#include "
microfmt.hpp
"
64
65
#if defined(MICROFMT_SHARED_BUILD)
66
// MICROFMT_API (see detail/compat.hpp) is the export attribute here --
67
// MICROFMT_SHARED_BUILD is defined, so it expands to `__declspec(dllexport)`
68
// / default visibility, never plain `inline` -- marking these explicit
69
// instantiation *definitions* as publicly visible symbols so that the
70
// `extern template` declarations below (seen by ordinary MICROFMT_SHARED
71
// consumers) can actually bind to them at link time.
72
#define MICROFMT_FORMATTER_INSTANCE(...) \
73
template struct MICROFMT_API microfmt::formatter<__VA_ARGS__>; \
74
template MICROFMT_API void microfmt::detail::format_type_thunk<__VA_ARGS__>(const void *, microfmt::string_view, \
75
const microfmt::sink &)
76
#elif defined(MICROFMT_SHARED)
77
// MICROFMT_API here expands to `__declspec(dllimport)` on MSVC (and to
78
// nothing elsewhere) -- MSVC requires the `extern template` declaration
79
// importing a dllexport-instantiated template to itself be decorated
80
// dllimport, or it silently re-instantiates its own local copy instead of
81
// binding to the shared library's definition above.
82
#define MICROFMT_FORMATTER_INSTANCE(...) \
83
extern template struct MICROFMT_API microfmt::formatter<__VA_ARGS__>; \
84
extern template MICROFMT_API void microfmt::detail::format_type_thunk<__VA_ARGS__>( \
85
const void *, microfmt::string_view, const microfmt::sink &)
86
#else
87
#define MICROFMT_FORMATTER_INSTANCE(...)
88
#endif
microfmt.hpp
Core formatting primitives, sinks, and customization point.
Generated by
1.9.8