I get the mentioned warning for the return below
void* findpath(const char *filename) { if (IoErr() == ERROR_OBJECT_IN_USE) return -1; }
The function is used as this
#define ZERO ((BPTR)NULL)
BPTR gcprog=ZERO;
if ((gcprog = findpath("Gui4Cli")) != ((BPTR)-1))
I get the same warning though with with
return (BPTR)-1;
How can i get rid of it?
If you declare your function as returning a void* you need to cast to void*. If you want to cast to BPTR, you should declare your function as returning a BPTR. Generally you should declare your function as true as possible. So if you return a BPTR, declare it as BPTR.
either
void* findpath()
{
return (void*) -1;
}
or
BPTR findpath()
{
return (BPTR) -1;
}
JoshDuchIt: What findpath is supposed to return ? A string ? If so, what about returning NULL and declaring the format of the return value as "char *" ?
But maybe you want to distinguish the error case ERROR_OBJECT_IN_USE and others.
@thomas, thanks
@corto
As shown in the usage of the function:
BPTR gcprog=ZERO;
and
if ((gcprog = findpath("Gui4Cli")) != ((BPTR)-1))
findpath would be OK if it returned a BPTR
I took over the suggestion of Thomas, and the stuff compiles OK now
Thanks too