VS Arduino
Visual Micro >> Visual Studio 2017, 2019, 2022 >> How to mark functions as deprecated?
https://www.visualmicro.com/forums/YaBB.pl?num=1566322087

Message started by Red Baron on Aug 20th, 2019 at 5:28pm

Title: How to mark functions as deprecated?
Post by Red Baron on Aug 20th, 2019 at 5: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)

Title: Re: How to mark functions as deprecated?
Post by Visual Micro on Aug 20th, 2019 at 7: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.

Title: Re: How to mark functions as deprecated?
Post by Red Baron on Sep 1st, 2019 at 8: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".


Title: Re: How to mark functions as deprecated?
Post by Visual Micro on Sep 1st, 2019 at 12:27pm
What are the "vMicro>Compiler>Warnings" options set to?

Title: Re: How to mark functions as deprecated?
Post by Red Baron on Sep 2nd, 2019 at 1:19pm
Thanks for the tip. That's it. I was quite blind.

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.