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 How to mark functions as deprecated? (Read 1860 times)
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
How to mark functions as deprecated?
Aug 20th, 2019 at 5:28pm
Print Post  
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)
Select All
#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
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to mark functions as deprecated?
Reply #1 - Aug 20th, 2019 at 7:23pm
Print Post  
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
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: How to mark functions as deprecated?
Reply #2 - Sep 1st, 2019 at 8:51am
Print Post  
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
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to mark functions as deprecated?
Reply #3 - Sep 1st, 2019 at 12:27pm
Print Post  
What are the "vMicro>Compiler>Warnings" options set to?
  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: How to mark functions as deprecated?
Reply #4 - Sep 2nd, 2019 at 1:19pm
Print Post  
Thanks for the tip. That's it. I was quite blind.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint