Error return values

I come funtcions, eg sem-open, the docs say that the function returns a
pointer, or else -1.

How can I check for thsi error condition??

eg
sem_t* sem_ptr;
sem_prt = sem_open(…)
if(sem_prt == -1)
{
/Error/
}
doesn’t work as I am comparing a pointer with an integer.

Cheers

Liam <liam.mcdermott@nuigalway.ie> wrote:

I come funtcions, eg sem-open, the docs say that the function returns a
pointer, or else -1.

How can I check for thsi error condition??

if( sem_ptr == (sem_t )-1 ) {
/
… */
}

or…

if( sem_ptr == SEM_FAILED ) {
/* … */
}

chris

\

Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/