Skip to content

Remove the TMC_IMPL macro requirement + enable building into a Windows DLL#207

Merged
tzcnt merged 8 commits intomainfrom
no_impl_windows_dll_accessors
Feb 10, 2026
Merged

Remove the TMC_IMPL macro requirement + enable building into a Windows DLL#207
tzcnt merged 8 commits intomainfrom
no_impl_windows_dll_accessors

Conversation

@tzcnt
Copy link
Copy Markdown
Owner

@tzcnt tzcnt commented Feb 9, 2026

Similar to how Asio does it, there are now 3 ways to build and link to TMC:

  • (nothing defined): everything is inline and the library is header-only.

  • TMC_STANDALONE_COMPILATION is defined: This is equivalent to the old behavior. The portions of TMC that can be compiled separately will be defined in the translation unit that defines the TMC_IMPL macro. Other translation units should also define TMC_STANDALONE_COMPILATION, but should not define TMC_IMPL.

  • TMC_WINDOWS_DLL is defined: Behaves similarly to TMC_STANDALONE_COMPILATION, except that functions and data in the compilation unit that defines TMC_IMPL will be decorated with __declspec(dllexport), so that you can build the implementation file into a DLL. Other translation units should also define TMC_WINDOWS_DLL, but should not define TMC_IMPL. In those translation units, the headers will decorate the necessary functions and data with __declspec(dllimport) so that they can be linked to the built DLL.


This change is backward compatible - any library that previously defined TMC_IMPL will still work, but the macro will be ignored by default and the header-only "inline" version will be used. Worst case, users may get an unused macro warning. Users can restore the prior functionality of separate compilation by defining TMC_STANDALONE_COMPILATION.


During the development of this feature I identified a critical miscompilation with MSVC Release builds. This is not new behavior with this update. I've filed a bug with Microsoft and updated the README to note that MSVC is not working.

@tzcnt tzcnt force-pushed the no_impl_windows_dll_accessors branch from 774225a to 80c5259 Compare February 9, 2026 02:56
@tzcnt tzcnt force-pushed the no_impl_windows_dll_accessors branch from 08cd8b0 to 7f85535 Compare February 10, 2026 01:29
@tzcnt tzcnt merged commit 359664d into main Feb 10, 2026
49 checks passed
@tzcnt tzcnt deleted the no_impl_windows_dll_accessors branch February 10, 2026 02:50
@tzcnt tzcnt linked an issue Feb 10, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows DLL linkage attributes

1 participant