Isn't there a conditional compiliation even now, all 6 years later?
Here's the half-baked, basic solution that I use for some of my apps. It isn't updated for VS Code tho.
EDIT…
I would love to have inline #ifdef / #ifndefs. That would solve all my maintenance problems instantly. I probably should've written that tool already.
Total newbie here, but I was writing pretty much exactly code like yours. To log interesting stuff only in debug mode. Soon did I find out I have to leave empty functions for release build. That seems really odd.
Isn't there a conditional compiliation even now, all 6 years later?
I'm now experimenting with "Prettier monkey C" which has code optimizer, maybe it could remove the empty functions and their call statements. It advertises removing dead code...
Isn't there a conditional compiliation even now, all 6 years later?
Here's the half-baked, basic solution that I use for some of my apps. It isn't updated for VS Code tho.
EDIT: There's a couple of other solutions in the thread which might be better, but I haven't tried them.
forums.garmin.com/.../solution-for-line-by-line-mc-conditional-compilation
I'm now experimenting with "Prettier monkey C" which has code optimizer, maybe it could remove the empty functions and their call statements. It advertises removing dead code...
I don't think it'll work for your use case since it operates before exclusions are processed by the compiler.
If you already use prettier, then just add (:inline) on the empty functions, it'll replace them with {} which doesn't add a byte to the bytecode. Another thing I use with prettier are boolean constants, ie:
Hey thanks, it almost works like this:
import Toybox.System; import Toybox.Lang; (:inline,:debug) function log(message as Lang.String) as Void { System.println(message); } (:inline,:release) function log(message as Lang.String) {}
But if I call it like this:
log("Did something important");
It optimizes it to this on release:
{ var message = "Did something important"; }
And on debug to this:
{ var message = "Did something important"; System.println(message); }
Annoyingly close! It still leaves that variable allocation there, maybe I try to report this on the prettier Github extension page as bug.
You can report it here: forums.garmin.com/.../big-update-to-prettier-extension-monkeyc
I don't think it's a bug, rather as a feature request:
"Remove" unused function arguments when inlining