Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
How to mark functions as deprecated? (Read 212 times)
Red Baron
Junior Member
**
Offline



Posts: 76
Germany
How to mark functions as deprecated?
Aug 20th, 2019 at 6:28pm
 
Hi,

I want to mark some (member) functions as deprecated. The hope was gettting a hint from intellisense or the compiler when using such a method. But I never received a warning from Intellisense or the compiler.

I'm using Visual Studio 2015. I tried this for Arduino Uno and for ESP8266 with no differences:

Code (CSS):
#if defined(__GNUC__)
#define DEPRECATED __attribute__((deprecated)) // GCC
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)      // Intellisense
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#endif

class A {
public:
  DEPRECATED void foo();
};

void setup() {
  A q;
  q.foo();
}
 



The code compiles witout a warning.

In Visual Studio I tried the same with a standard console c++ program. There I got the message
'A::foo': wurde als veraltet deklariert (German, meaning is, 'A::foo' is deprecated)
Back to top
 

WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10565
United Kingdom
Re: How to mark functions as deprecated?
Reply #1 - Aug 20th, 2019 at 8:23pm
 
We use standard visual studio c++ in the ide and standard gcc for compile. So whatever they support is at your disposal.

If I recall visual studio is very good at showing comments in hints and intellisense. Put any comment you like before any item and I think it's automatic.

Also I think adding \\\ before a method automatically extracts the method signature to the comment.
Back to top
 
WWW  
IP Logged
 
Red Baron
Junior Member
**
Offline



Posts: 76
Germany
Re: How to mark functions as deprecated?
Reply #2 - Sep 1st, 2019 at 9:51am
 
Yes, comments just above a function declaration are shown by intellisense.

But I'm still unable to get a warning message to the output window or the error list window. Even a simple #warning statement like
   #warning "this is a warning"
has no effekt. #error works as expected. The compiler shows the message and terminates.

What do I have to do, that these warnings are displayed? I've spent a lot of time for searching for hints in the web. Unsuccessfully. Are there any switches, defines or anything similar I have to set up?

I'm using VS 2017, VM 19.0. I have tried several boards/compilers (ESP8266, Arduino uno, Arduino due (ARM)).

The VS output window has the title "Micro Build".

Back to top
 

WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10565
United Kingdom
Re: How to mark functions as deprecated?
Reply #3 - Sep 1st, 2019 at 1:27pm
 
What are the "vMicro>Compiler>Warnings" options set to?
Back to top
 
WWW  
IP Logged
 
Red Baron
Junior Member
**
Offline



Posts: 76
Germany
Re: How to mark functions as deprecated?
Reply #4 - Sep 2nd, 2019 at 2:19pm
 
Thanks for the tip. That's it. I was quite blind.
Back to top
 

WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print