In the Microsoft world, __declspec(dllexport)
makes a function or class callable from outside the DLL.
When you create a DLL, by default, any functions defined within the DLL are only callable from that same DLL. You cannot call that function from an executable or a different DLL.
If you want your a function to be called from outside the DLL, you need to export it by adding __declspec(dllexport)
.
One way to think about it is that __declspec(dllexport)
marks a function as being part of a DLL's public interface.
While you didn't ask about __declspec(dllimport)
that is sort of the opposite. When calling a function in a different DLL, your DLL needs to know that it's part of a differernt DLL's public interface so it can properly handle the call (calling a function in a different DLL requires more complex code that calling a function in yourself).