472,787 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,787 software developers and data experts.

error: invalid operands to binary &

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
4 31216
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

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
3
by: Kaidi | last post by:
Hello guys, I get the "an invalid XML character" error when using xerces to parse a XML file. I know that XML will correspond the &, <, >, " to special strings like "&gt;&lt;". However, how about if the...
4
by: August Karlstrom | last post by:
Hi, How come the modulus operator doesn't always yield non-negative values? I expect e.g. (-1) % 3 to be 2 but I get -1. If I want to decrement a cyclic variable n by k I have to write something...
24
by: Noah Roberts | last post by:
Item #1 in the More Exceptional C++ book uses the following construct: fstream in; .... process( in.is_open() ? in : cin,...); Where process has been shown as having various multiple...
1
by: Richard Eich | last post by:
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3) source snippet: .... int i = 17 ; if ( 0x03 & i ) ....
4
by: John Doe | last post by:
segmentation error !!!! hi guys , i wrote this program to multiply two matrices (just the basic code without checkin 4 the condition n==p ) " #include<stdio.h> main() { int a,b,c; int...
2
by: xelloss | last post by:
#include<cstdlib> #include<iostream> #include<iomanip> #include<vector> #include<fstream> using namespace std; double sum(vector<double> x) { double total = 0.0;
63
by: Kapteyn's Star | last post by:
Hi newsgroup The program here given is refused by GCC with a error i cannot understand. It says rnd00.c: In function ‘main’: rnd00.c:26: error: expected expression before ‘]’ token ...
3
by: Shantanu Godbole | last post by:
temp1 = number%pow(10,i)/pow(10,i-1); An error is shown in this line even though i include math.h library and use the correct operators ERROR: invalid binary operands to % How to deal with it?
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.