Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Debug preprocessor definition? (Read 12687 times)
CapnBry
Junior Member
**
Offline


Posts: 32
Joined: Nov 4th, 2011
Debug preprocessor definition?
Oct 27th, 2012 at 12:30pm
Print Post  
I see that MICRO_DEBUG and VMDEBUG are both set when compiling sketches in "Debug" mode. Are these synonymous? Are they both always going to be present when set to debug mode? Are there any plans to add the standard _DEBUG definition when compiling for the debug target (regardless of if the 'Micro Debug' is set)?

I ask because I have a few debug functions I'd rather not compile into releases, so relying on the _DEBUG would be helpful. I realize that means it will compile differently in Arduino vs VM.

I also want to up the serial speed in my sketch when compiled for 'Micro Debug', so which should I key off of, MICRO_DEBUG or VMDEBUG?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug preprocessor definition?
Reply #1 - Oct 27th, 2012 at 1:32pm
Print Post  
Great question, I've been hoping to get some input on this topic. 

I asked on the arduino dev channel if we could agree a standard but the answer became complicated by to many clever people with better ideas! Not.

So are you using #define _DEBUG? Is that the standard I am happy to implement it if so? I thought it was #define DEBUG which appears to be the MS standard but has been used by some people in their Arduino projects already.

It might need to be an option because some people will have used it and not want it enabled during a VS debug session???

There can be more than one, so which of the current defs do you think we should keep? It's easy enough to keep both but would be better with one.

Sorry I don't have a direct answer except to say it can be whatever you want


  
Back to top
IP Logged
 
CapnBry
Junior Member
**
Offline


Posts: 32
Joined: Nov 4th, 2011
Re: Debug preprocessor definition?
Reply #2 - Oct 27th, 2012 at 4:58pm
Print Post  
Haha yeah I find that all the Arduino information streams are chock full of people who have very little experience in C coding.

The standard visual studio compiler adds the _DEBUG define if you specify /MTd or /MDd on the command line. If you use it automatically or specify it manually it will also link debug libraries.

I agree there should be just one define for when Micro Debug is on. Maybe have it undefed if no VM debug is on, and then hold a value if it is which corresponds to the level of debug enabled (I think there's just full=1 now right?)

What I've been doing currently is just adding _DEBUG to the global "additional preprocessor" defines property and then just removing it when I switch back. I love *love* that feature of Visual Micro, although I would like it more if the value were stored per-configuration (release/debug).
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug preprocessor definition?
Reply #3 - Oct 27th, 2012 at 5:19pm
Print Post  
That sounds good. I thought the standard was DEBUG not _DEBUG. 

It seems to make sense to have only _DEBUG and _VMDEBUG in future release and to dump MICRO_DEBUG and VMDEBUG? I can't see the wood for the trees on this at the moment (head full) so feel free to make it easy and tell me what to do Cheesy

The idea behind the current (Micro Debug) was to give an option in the future that would #define the pre-processor settings but not do any c++ code injection.
Code
Select All
None
Full
Pre-Proc Only 



Your suggestion of different levels falls in line with some requests from the arduino dev board. Some people suggested that they have their own custom debug levels per project. It would be nice to consider how these levels might be defined so that they are known to VM with pretty names. This would allow a combo choice list in the project properties. But is this going to far? Are there some simpler standards that you are used to working with?

Quote:
stored per-configuration (release/debug).


Yes I agree and was planning for both types. Ones that are global and always applied (existing) and ones stored per-release.
« Last Edit: Oct 27th, 2012 at 5:21pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug preprocessor definition?
Reply #4 - Oct 28th, 2012 at 2:42am
Print Post  
Next release has two options (preprocessor renamed to constants):-

Constants - Project
Constants - Configuration

"Constants - Project" is the old "Additional Preorocessor" setting

At the moment, visible code "enabling/disabling" based on #defines only detects the change when you perform an action such as change config, compile etc.

If you can think of better names please let me know
« Last Edit: Oct 28th, 2012 at 2:43am by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug preprocessor definition?
Reply #5 - Oct 28th, 2012 at 3:52am
Print Post  
In the next release a new integer project property called "Define DEBUG Constant" is available. 

The property is specific to each configuration name.

The property is part of the standard plugin and unconnected to the debugger. It #defines _DEBUG to the value specified.

A value of 0 (default) causes it not to be defined.

This leaves the real vm constants unpublished and available for other purposes.

EDIT: Let me know if you think we should have the levels in a different define. or something better
« Last Edit: Oct 28th, 2012 at 5:34pm by Tim@Visual Micro »  
Back to top
IP Logged
 
CapnBry
Junior Member
**
Offline


Posts: 32
Joined: Nov 4th, 2011
Re: Debug preprocessor definition?
Reply #6 - Oct 30th, 2012 at 4:08pm
Print Post  
Yeah having the number for a debug level might be overkill but if you're going to define it, you might as well have the ability to give it a value right? Just as long as 0 means "not defined" because everything I've seen goes with the syntax:
#if _DEBUG
// foo
#endif

I don't know if calling the the preprocessor definitions "constants" is immediately obvious what they are. I would think calling them "Defines" would better indicate they are -D options, and you'd have 
Defines - All Configurations
Defines - Configuration
Which would be more in line with what terms Visual Studio normally uses to describe per-config and global settings. Ideally it would say "preprocessor definitions" but I realize that space is at a premium in the project properties toolwindow.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debug preprocessor definition?
Reply #7 - Oct 30th, 2012 at 4:14pm
Print Post  
Yes 0 certainly means not defined.

Okay defines is better. I used constants because that's what the are called on the Vs C++ options but I agree it doesn't seem obvious or right
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint