Skip to content

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

Open
tzcnt wants to merge 7 commits intomainfrom
no_impl_windows_dll_accessors
Open

Remove the TMC_IMPL macro requirement + enable building into a Windows DLL#207
tzcnt wants to merge 7 commits intomainfrom
no_impl_windows_dll_accessors

Conversation

@tzcnt
Copy link
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 require standalone compilation will be compiled 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 an issue when building with MSVC + Release. This issue was present prior to making any changes. This may be a bug in the library or it could be a miscompilation (it wouldn't be the first time). Using clang-cl.exe works. I'll be investigating this next before pursuing any other features.

@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 80c5259 to 294ca23 Compare February 9, 2026 03:02
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.

1 participant