I don’t think Lua has any precompiler commands, certainly I’ve never seen anything about them.
As I mentioned before, I use an Ant script to comment out all of my print commands, and then reverse that when I go back to debugging (projectDir is the location of your Corona project):
\<!-- COMMENT ALL INSTANCES OF PRINT --\> \<replaceregexp byline="true" match="print\((.\*)" replace="--RELEASEPRNT\(\1"\> \<fileset dir="${projectDir}"\> \<include name="\*.lua"/\> \</fileset\> \</replaceregexp\> \<!-- UNCOMMENT ALL INSTANCES OF PRINT --\> \<replaceregexp byline="true" match="--RELEASEPRNT\((.\*)" replace="print\(\1"\> \<fileset dir="${projectDir}"\> \<include name="\*.lua"/\> \</fileset\> \</replaceregexp\>
One thing to mention is that this will break your code if you have any inline print statements. For example this:
if something then print("something happened") end
would become this:
if something then --RELEASEPRNT("something happened") end
and so the “end” would be commented out and the if statement would be broken.
To fix this just change any inline print calls so they are on multiple lines:
--now this if something then print("something happened") end --becomes this if something then --RELEASEPRNT("something happened") end
@thomas6 - to a certain degree I would agree with you, for instance when you just print things like “aaa”, “bbb” etc to try and find exactly where some code is breaking then yes I would remove those after the problem is fixed.
But for a larger project, having print statements in the project is still useful throughout debugging. It’s very easy to change one part of the project and accidentally have it affect another part, so having a healthy amount of data printing out is extremely useful. I’m not saying that my method is perfect, but it lets me have as much output as I like during debugging, and zero print calls being made on release builds, which seems pretty good to me.