ID:96337
 
Redundant
Applies to:DM Language
Status: Redundant

This feature has already been implemented, or is already achievable with existing methods.
I need a method to quickly and easily determine whether or not a file has been included in the DME or not and be able to write code accordingly. So in the spirit of #ifdef, I've come up with this.

mob
verb
test()
#ifinc "myfile.dm"
myProc() // Proc exists in "myfile.dm"
#else
myOtherProc() // Code exists in already included files.
#endif


It would be possible for me to keep track of included files within the code itself, but then I'd lose that lovely feeling I get knowing my code will still compile the second I uncheck a file in the file-tree.

Naturally, this little devil could also be used for files within the BYOND library bin:
mob
verb
test()
#ifinc <tiberath.myusefulbutunnecessarylib>
myProc()
#else
myOtherProc()
#endif
Wouldn't it simply be possible to put a #define in the library itself that you could check for using #ifdef?
Lummox JR wrote:
Wouldn't it simply be possible to put a #define in the library itself that you could check for using #ifdef?

That would only work in a library scenario. If I have a datum which contains offshoots in other files, but could technically opperate independantely of one another if I know that the other file is or is not included, I'm royally boned without a means to determine whether or not the other portions are included.

That sounds like it could be sovled with #define, but file 1 can't check an #ifdef of file 2, as the definition for it is below it in the file tree, resulting in the compiler stating the definition doesn't exist in the first place.
I recently fell into the same boat, or at least a boat of similar make and model.

I had two libraries. One fed off of most of the functionality of the other, but if the other wasn't present, I needed to instruct it to act alone.

I just put a "1-" & "-2" at the beginning of the file names so that one would always be in front of the other and used #define and #ifdef.

P.S. But it would have been a lot "neater" had there been and #ifinc preprocessor.
Ter13 resolved issue (Redundant)

Build order management can be performed by editing the .dme file and using the #include directive manually, as well as the #define preprocessor.