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

Add dllexport/dllimport to make it easier to use Sonic as a DLL #54

Open
gexgd0419 opened this issue Jan 14, 2025 · 0 comments
Open

Add dllexport/dllimport to make it easier to use Sonic as a DLL #54

gexgd0419 opened this issue Jan 14, 2025 · 0 comments

Comments

@gexgd0419
Copy link

There's no __declspec(dllexport) or __declspec(dllimport) in the header file, so Sonic cannot be used directly as a DLL without modification, because nothing would be exported. Compiling a Windows DLL requires functions to be explicitly exported.

A .def file can be added to export the functions as a workaround. However, the same header file is usually used when importing the functions as well. Without __declspec(dllimport), the compiler will assume that it is a regular extern function, and some optimizations for imported functions will not be applied.

To support compiling to both DLL and static library, #ifdef can be used to check a specific macro, for example SONIC_DLL. If not defined, __declspec(dllexport) and __declspec(dllimport) will not be added to keep the original behavior. Those who want to use Sonic as a DLL would have to predefine this macro.

There's a related pull request #27 but it hasn't been merged or closed for a long time. So @waywardgeek what's your thought about that?

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

No branches or pull requests

1 participant