__declspec(dllexport) on classes and class members is very, veryfragile. What is the purpose of the separate server.dll? Really the only thing __declspec(dllexport) on a class does well is reducing process startup I/O, when it is paired with /delayload:server.dll. Any other perceived advantages (e.g. imagined ability to patch DLL logic without recompiling the application) are actually violations of the One-Definition-Rule and unreliable.
–
Ben VoigtDec 20 '10 at 14:38

@Ben Voigt: you surprise me. That's a different discussion, really. But the intent here is to decouple code into a gazillion of libraries, an not all 'server' libraries are needed by all 'client' libraries.
–
xtoflDec 20 '10 at 14:56

2 Answers
2

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.

From the linked article: <quote>For data, it is required for correctness.</quote>
–
Ben VoigtDec 20 '10 at 14:43

Thanks! You pointed to the right blog post. Your phrasing is a bit confusing, though - I thought that the importing source would result in a call to the __imp_foo thunk in the importing code.
–
xtoflDec 20 '10 at 14:45