Monkey Forums/Monkey Beginners/Preprocessor

k.o.g.(Posted 2014) [#1]

It would be cool, to have in monkey vars like "__FUNCTION__","__LINE__"....

Any chance, that somebody want make this working with transcc?


ImmutableOctet(SKNG)(Posted 2014) [#2]
I don't think you can do this for functions and lines, but you can report the current module's path with "${MODPATH}"/'MODPATH' (Similar to '__FILE__' from what I remember).

This would be nice to have for functions, though. As far as '__LINE__' is concerned, that's a bit odd. '#Error' already says the number, but the contents of the line is a different story. The current loading process could actually support these things, so it's definitely possible. To tell you the truth, a "#Warning" directive would be nice. I'm always for expanding the preprocessor, and I'd really like to see something like '__DATE__' added. I also really want to see a way of using preprocessor strings as normal strings, but I don't think Mark's too keen on this idea.

You could always make this specific to your own version of 'trans'. It ignores "${X}" if 'X' is undefined (You can use "${}" with any preprocessor variable). So, technically, it's perfectly possible to add/define this in/to your own version of 'trans', while still supporting standard versions of Monkey. The "#Warning" thing is a different story (Backward-compatibility-wise).