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 inherrit #define from .ino into custom class (Read 1516 times)
chlore
Junior Member
**
Offline


Posts: 11
Joined: Oct 1st, 2015
inherrit #define from .ino into custom class
Aug 31st, 2016 at 11:15pm
Print Post  
I have three instances of visual studio 2015 with visual micro installed.  On one of the instances my #defines placed in the top level .ino are global or at least inherited into my sub/derived classes that are consumed by the code placed in the .ino file.

Is there a setting I am missing to enable this "feature" or has this been removed in a later version (it is possible I am running multiple visual micro versions across my pc's)?  The instance the global #defines is working on is a pc I won't have access to till tomorrow.
so baring checking the other pc visual micro version...  

Is there a recommended way to have a single place to put #defines that are consumable by all classes in a project that does not rely on the custom visual micro #define preprocessor macro?  
-chlore
« Last Edit: Aug 31st, 2016 at 11:16pm by chlore »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: inherrit #define from .ino into custom class
Reply #1 - Sep 1st, 2016 at 2:15am
Print Post  
Hi,

As far as #defines in code is concerned it's just down to the arduino/gcc/c++ rules and Visual Micro has no control over that. I thought people do put global #defines in files but often via an #include "myheader.h" or some other header file.

You can also add your own defines in the visual micro project properties either for all configurations and/or per configuration (ie: different between release and debug configurations) 

The project property version are carried through all compiler commands so can be used to affect code outside of the project code such as libraries.

The documentation on visualmicro.com shows some facilities/User-Guide.aspx?doc=Project-Defines.html

If I recall you can ; separate one=1;two=2

or you can add them to the compiler flags, again in the same project properties as the defines. In that case they will be defined like this:-

-Done=1 -Dtwo=2

The vMicro>Compiler>Verbose option can be used to see what defines are currently being used by the compiler.

Final thought

The nice thing about putting them in code is that your code will still work in the Arduino IDE
« Last Edit: Sep 1st, 2016 at 2:17am by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint