0

Sorry this seems like a noddy question but how do you get the compiler to generate a warning when a certain variable / structure is used?

For example if I have the following code:

   int GetAbstractedFoo()
   {
        return 1;
   }
   struct new_name
   {
        int foo;
   }
   typedef new_name old_name;

How do i do a #warning to say "warning "old_name" is depreciated please use new_name"

and expanding on that further how could is say "warning accessing foo directly has been depreciated please use "abstractedFoo"?

I have had trouble googling this beyond the basic #warning when a header is used.

-Thanks, Chris

chrispepper1989
  • 2,100
  • 2
  • 23
  • 48

1 Answers1

0

Ah so a bit more digging and I came across this post and the fab answer by Michael Platings:

C++ mark as deprecated

I think for my purposes I shall extend the macro to:

#define DEPRECATE( var , explanation )   var __attribute__((availability(myFramework,introduced=1,deprecated=2.1,obsoleted=3.0, message= explanation)));

DEPRECATE ( typedef old_name new_name, “please use new_name”);
Community
  • 1
  • 1
chrispepper1989
  • 2,100
  • 2
  • 23
  • 48