Quote:Original post by Giallanon
If I staticaly link a DLL with another DLL or with and exe, there is no need to dllimport any functions.
All I need is __dllexport (or to use a .def file), include the right .h and the compiler will work just fine.
So I still don't understand the use of __declspec(dllimport)
I think you're either misunderstanding something here or using the wrong terminology, you cannot by definition "statically link to a dll", you can link to a static library (.lib) or link to a dynamic library (.dll), so "statically linking to a dll" is an oxymoron. The .lib file you link to when linking to a dll does not contain any object code and is just a helper to get to the dll.
I don't know exactly what are you doing here, as far as I understand it, you do need __declspec(dllimport) to let the linker know that it should look for the function or resource address during the program loading stage, rather than hardcode it to a known piece of object code even if linking against the "helper" lib file rather than the static one.
In short, __declspec(dllimport) is needed to let the
dynamic linker know that it should look for the resource in an external PE file (exe/dll), if you link to a static library, the object code for the function is internally copied into the executable, so no need for __declspec(dllimport).