Can I use #ifdef
sections in a .def
file for a dll? E.g.:
LIBRARY "mydll"
EXPORTS
checkRequirements
createDevice
installDriver
isPastVersionInstalled
removeDevice
#ifdef myVar
doSomethingElse
#endif
No, not possible, it is not a file that's pre-processed. Although I supposed you could by running the preprocessor to generate another .def file and link that one.
The more effective approach is to eliminate the need for a .def file completely. Use __declspec(dllexport) in your code on the functions that should be exported. Then any #ifdef in that code will automatically ensure that a function is neither compiled nor exported.