How to turn off deprecated warnings

Have a question about our Software Developer Kit? Ask them here.
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

How to turn off deprecated warnings

Post by softwarefailure »

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...
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: How to turn off deprecated warnings

Post by xenic »

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
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: How to turn off deprecated warnings

Post by salass00 »

The way to turn off deprecated warnings in gcc is to use the command line option "-Wno-deprecated-declarations".
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: How to turn off deprecated warnings

Post by softwarefailure »

@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...
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: How to turn off deprecated warnings

Post by broadblues »

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.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: How to turn off deprecated warnings

Post by xenic »

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
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: How to turn off deprecated warnings

Post by softwarefailure »

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;
}
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: How to turn off deprecated warnings

Post by salass00 »

-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=".
softwarefailure
Posts: 112
Joined: Fri Feb 14, 2014 10:29 pm

Re: How to turn off deprecated warnings

Post by softwarefailure »

Okay, -DDEPRECATED= does the trick. A more elegant solution like -D__NO_DEPRECATED__ would be nice, though.
User avatar
Thomas Frieden
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 147
Joined: Fri Dec 10, 2010 3:21 pm

Re: How to turn off deprecated warnings

Post by Thomas Frieden »

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
Post Reply