Page 1 of 3

How to turn off deprecated warnings

Posted: Tue Apr 21, 2015 5:35 pm
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...

Re: How to turn off deprecated warnings

Posted: Tue Apr 21, 2015 8:21 pm
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

Re: How to turn off deprecated warnings

Posted: Tue Apr 21, 2015 8:25 pm
by salass00
The way to turn off deprecated warnings in gcc is to use the command line option "-Wno-deprecated-declarations".

Re: How to turn off deprecated warnings

Posted: Tue Apr 21, 2015 8:50 pm
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...

Re: How to turn off deprecated warnings

Posted: Tue Apr 21, 2015 10:00 pm
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.

Re: How to turn off deprecated warnings

Posted: Wed Apr 22, 2015 7:30 pm
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.

Re: How to turn off deprecated warnings

Posted: Wed Apr 22, 2015 7:58 pm
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;
}

Re: How to turn off deprecated warnings

Posted: Wed Apr 22, 2015 8:09 pm
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=".

Re: How to turn off deprecated warnings

Posted: Wed Apr 22, 2015 8:34 pm
by softwarefailure
Okay, -DDEPRECATED= does the trick. A more elegant solution like -D__NO_DEPRECATED__ would be nice, though.

Re: How to turn off deprecated warnings

Posted: Thu Apr 23, 2015 9:39 am
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