This is the way to do it in D: // ---------- first module ---------- module first;
enum USE_MY_API = true; /* * My API implementation. */ // ---------- second module ---------- module second; import first; static if (USE_MY_API) { // My API usage. } One idiom used in C/C++ is #if API_VER >= 0xABCD .... #end if Which naturally maps to static if, which can refer to symbols in other modules.