How to turn off deprecated warnings

Have a question about our Software Developer Kit? Ask them here.

How to turn off deprecated warnings

Postby softwarefailure » Tue Apr 21, 2015 6:35 pm

For portability's sake I'm compiling using __USE_INLINE__ defined. I'm getting lots of deprecated warnings now for basic functions like AllocVec(), CreateIORequest(), CreateMsgPort() .... you can imagine that I don't care at all that someone decided to declare these 'deprecated' on OS4 because they're essential for cross-platform Amiga development. So how do I turn off these warnings?

Note that I do not want to turn off gcc deprecated warnings in general using -Wno-deprecated but just the OS4 specific deprecated warnings...
softwarefailure
 
Posts: 45
Joined: Fri Feb 14, 2014 11:29 pm

Re: How to turn off deprecated warnings

Postby xenic » Tue Apr 21, 2015 9:21 pm

softwarefailure wrote:For portability's sake I'm compiling using __USE_INLINE__ defined. I'm getting lots of deprecated warnings now for basic functions like AllocVec(), CreateIORequest(), CreateMsgPort() .... you can imagine that I don't care at all that someone decided to declare these 'deprecated' on OS4 because they're essential for cross-platform Amiga development. So how do I turn off these warnings?

Note that I do not want to turn off gcc deprecated warnings in general using -Wno-deprecated but just the OS4 specific deprecated warnings...


I think the decision to declare them 'deprecated' was done for a reason. Some replacement functions provide additional functionality or address shortcomings of the OS3 functions. You'd be better off adding #ifdefs to use the OS4 functions for OS4 binaries but if you really want to use the oudated functions add these lines above any system includes:

#ifdef __amigaos4__
#undef DEPRECATED
#define DEPRECATED
#endif
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 934
Joined: Sun Jun 19, 2011 1:06 am

Re: How to turn off deprecated warnings

Postby salass00 » Tue Apr 21, 2015 9:25 pm

The way to turn off deprecated warnings in gcc is to use the command line option "-Wno-deprecated-declarations".
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 459
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: How to turn off deprecated warnings

Postby softwarefailure » Tue Apr 21, 2015 9:50 pm

@xenic: Hacking system includes is what I want to avoid of course.

@salass00: Did you read my original post?

Note that I do not want to turn off gcc deprecated warnings in general using -Wno-deprecated but just the OS4 specific deprecated warnings...
softwarefailure
 
Posts: 45
Joined: Fri Feb 14, 2014 11:29 pm

Re: How to turn off deprecated warnings

Postby broadblues » Tue Apr 21, 2015 11:00 pm

The correct aproach would be to "fix" the warning by writing short portbailty stubs or using macros where needed so that the replacement function are used when compiled for AmiagOS4, this greatly increase the futureprooffness (sic) of your code.

eg

Code: Select all
struct MsgPort *MVCreatePort(CONST_STRPTR name, UBYTE pri)
{
#if defined(__amigaos4__)
   return AllocSysObjectTags(ASOT_PORT,ASOPORT_Name,name,ASOPORT_Pri,pri,TAG_DONE);
#else
   return CreatePort(name,pri);
#endif
}

void MVDeletePort(struct MsgPort *port)
{
#if defined(__amigaos4__)
   FreeSysObject(ASOT_PORT,port);
#else
   DeletePort(port);
#endif
}



If that is really a problem for you then try simply adding -DDEPRECATED to the compile line as the OS include that defines DEPRICATED as __attribute__((depricated)) only does it if DEPRECATED is not already defined.
User avatar
broadblues
Beta Tester
Beta Tester
 
Posts: 391
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: How to turn off deprecated warnings

Postby xenic » Wed Apr 22, 2015 8:30 pm

softwarefailure wrote:@xenic: Hacking system includes is what I want to avoid of course.

I didn't intend for you to add the suggested lines in the system includes. Add those lines IN YOUR PROGRAM includes above any system includes. If you have a header file that includes most of the system header files then you can put the lines I suggested above the system header files in that file. It amounts to the same thing as Broadblues suggests (i.e. adding -DDEPRECATED to the compile line) but without changing your makefile.
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 934
Joined: Sun Jun 19, 2011 1:06 am

Re: How to turn off deprecated warnings

Postby softwarefailure » Wed Apr 22, 2015 8:58 pm

Doesn't work:

Code: Select all
7.DEV:> gcc -D__USE_INLINE__ -DDEPRECATED test.c
In file included from /SDK/include/include_h/proto/exec.h:30,
       from test.c:6:
/SDK/include/include_h/interfaces/exec.h:40: error: expected specifier-qualifier-list before numeric constant
test.c: In function 'main':
test.c:10: error: 'struct ExecIFace' has no member named 'AllocVec'
test.c:12: error: 'struct ExecIFace' has no member named 'FreeVec'


Source:

Code: Select all
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

#include <proto/exec.h>

int main(int argc, char *argv[])
{
    UBYTE *test = AllocVec(1024, MEMF_ANY);

   FreeVec(test);

   return 0;
}
softwarefailure
 
Posts: 45
Joined: Fri Feb 14, 2014 11:29 pm

Re: How to turn off deprecated warnings

Postby salass00 » Wed Apr 22, 2015 9:09 pm

-DDEPRECATED is IIRC equivalent to:

#define DEPRECATED 1

Adding the following line to the top of your source code file (before any #include statements) should work:

#define DEPRECATED

Or just adding the commandline option "-DDEPRECATED=".
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 459
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: How to turn off deprecated warnings

Postby softwarefailure » Wed Apr 22, 2015 9:34 pm

Okay, -DDEPRECATED= does the trick. A more elegant solution like -D__NO_DEPRECATED__ would be nice, though.
softwarefailure
 
Posts: 45
Joined: Fri Feb 14, 2014 11:29 pm

Re: How to turn off deprecated warnings

Postby Thomas Frieden » Thu Apr 23, 2015 10:39 am

softwarefailure wrote:Okay, -DDEPRECATED= does the trick. A more elegant solution like -D__NO_DEPRECATED__ would be nice, though.


The point of flagging things as deprecated is to give a hint to developers to change their code to no longer use the deprecated function. As such, a special "__NO_DEPRECATED__" is an absolute no-go. The only sensible solution would be to couple this to __USE_INLINE__ since this is a macro to ensure backward compatibility
User avatar
Thomas Frieden
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 144
Joined: Fri Dec 10, 2010 4:21 pm

Next

Return to SDK Support

Who is online

Users browsing this forum: No registered users and 1 guest