Can I use #ifdef in .def?

Can i use sections #ifdefin a file .deffor dll? For instance:.

LIBRARY "mydll"
EXPORTS
  checkRequirements
  createDevice
  installDriver
  isPastVersionInstalled
  removeDevice
  #ifdef myVar
  doSomethingElse
  #endif
+3
source share
2 answers

No, this is not possible, this is not a file that has been preprocessed. Although I suggested that you could run the preprocessor to create another .def file and link it.

A more efficient approach is to completely eliminate the need for a .def file. Use __declspec (dllexport) in your code for functions that need to be exported. Then any #ifdef in this code automatically ensures that the function is not compiled or exported.

+2
source

, .def , () mydll.def.in, .def .

Linux :

cpp -DmyVar=1 mydll.def.in > mydll.def

, Windows, , .

, , , , C, , . Gcc --traditional-cpp, , ​​ .

+1

All Articles