i saw today in the exmaples that they used this in the code .
#if DEBUG
Debug.Print(e.Message);
#endif
So that made me think, if one does not use the #if and i switch to release mode, when then happens to the Debug.Print(e.Message); ?
In other words, after i disconnect the usb debug cable and turn the board on, is it still chewing up some cycles trying to do it, or is it smart enough to realize that its not connected and does not bother with it.
Unfortunately, this is true and is what I would consider a bug in NETMF. In the full .NET, the Debug class is skipped during a release build and it is therefore unnecessary to put in a #if block.
I think this is especially confusing (or maybe misleading is a better word) for people coming from C/C++, where they’re used to things getting #ifdef’ed out when DEBUG isn’t defined…
If I had a vote, I’d vote that the Debug class got compiled into stubs or, better, nothing at all when built in release mode. That maybe or have a new class that gets compiled away into nothing in release builds and calls the existing Debug stuff in debug builds…
I often #ifdef out debug.print statements even when doing debug builds (I don’t like to depend on just the distinction between a debug adn release build.) You don’t always want them to be working as it can really slow things down and it can be helpful to be able to selectively turn groups of them on/off independently. You might also find that it might be helpful to have a few left on in a release build so you can connect with MFdeploy and monitor a device during long term testing.
For production code I would add a few lines to squirt out a warning if you leave any of the debug.prints on when doing a release build.
[quote]For production code I would add a few lines to squirt out a warning if you leave any of the debug.prints on when doing a release build.
[/quote]
Interesting idea… How do you detect this? Is there a OnDebugPrint event or something that could be handled to blink an LED or something?
There is no such compile time warning that I’m aware. I gathered that Jeff is already providing such a warning. Is this something you’re already doing or a warning you wish for?
I don’t see how that would help notify you that you forgot to #if a debug function. If you you remembered to #warning then you would certainly remember to #if. Is there a global application of #warning I’m not understanding? Sorry, it’s still early…