By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

error: invalid operands to binary &

P: n/a
In the following code it gives the error "error: invalid operands to
binary &"
Why it is happening

#include <signal.h>
#include <errno.h>

#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.husually defines NSIG to include signal number 0 */

int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= 1 << (signo - 1); // error
return(0);
}

int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set &= ~(1 << (signo - 1)); // error
return(0);
}

int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

return( (*set & (1 << (signo - 1))) != 0 ); //error
}

please give me the solution
With Regards,
Sureshlingam

Jul 17 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
muthu wrote:
In the following code it gives the error "error: invalid operands to
binary &"
Why it is happening

#include <signal.h>
#include <errno.h>

#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.husually defines NSIG to include signal number 0 */

int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= 1 << (signo - 1); // error
return(0);
}

int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set &= ~(1 << (signo - 1)); // error
return(0);
}

int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

return( (*set & (1 << (signo - 1))) != 0 ); //error
}

please give me the solution
With Regards,
Sureshlingam
I suppose problem is with sigset_t data type because this could be
implemented as integer type or a strucure type. In your case it seems
that it is defined as a structure.

Jul 17 '06 #2

P: n/a

muthu wrote:
In the following code it gives the error "error: invalid operands to
binary &"
Why it is happening

#include <signal.h>
#include <errno.h>

#define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG)
/* <signal.husually defines NSIG to include signal number 0 */

int
sigaddset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set |= 1 << (signo - 1); // error
return(0);
}

int
sigdelset(sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

*set &= ~(1 << (signo - 1)); // error
return(0);
}

int
sigismember(const sigset_t *set, int signo)
{
if (SIGBAD(signo)) { errno = EINVAL; return(-1); }

return( (*set & (1 << (signo - 1))) != 0 ); //error
}

please give me the solution
With Regards,
Sureshlingam
*set is of type sigset_t which on my system is a structure.
You cannot apply the binary operators to structures. But
to be sure check how sigset_t is defined on your system.

Spiros Bousbouras

Jul 17 '06 #3

P: n/a
sp****@gmail.com wrote:
>
*set is of type sigset_t which on my system is a structure.
You cannot apply the binary operators to structures.
You need to use sigaddset(), sigdelset(), and friends to manipulate a
sigset_t.

-Larry Jones

Monopoly is more fun when you make your own Chance cards. -- Calvin
Jul 17 '06 #4

P: n/a
la************@ugs.com writes:
sp****@gmail.com wrote:
>>
*set is of type sigset_t which on my system is a structure.
You cannot apply the binary operators to structures.

You need to use sigaddset(), sigdelset(), and friends to manipulate a
sigset_t.
And if you have more questions about these functions, you need to ask
elsewhere, probably in comp.unix.programmer. (This is addressed to
the OP, not to spibou or lawrence.jones.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.