Why/when is __declspec( dllimport ) not needed?

It isn’t required. It is an optimization, a hint to the compiler that the DLL is going to export the function pointer directly rather than just an entry in the IAT of the DLL. The exported function pointer for a function named foo() will be __imp_foo. Which allows it to generate better code, saving a function pointer load from the IAT and an indirect jump. It is a time optimization, not space.

This blog post has the details.

Leave a Comment