473,661 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.husuall y defines NSIG to include signal number 0 */

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

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

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

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

int
sigismember(con st 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 31379
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.husuall y defines NSIG to include signal number 0 */

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

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

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

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

int
sigismember(con st 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.husuall y defines NSIG to include signal number 0 */

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

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

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

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

int
sigismember(con st 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.co m 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.co m 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.progr ammer. (This is addressed to
the OP, not to spibou or lawrence.jones. )

--
Keith Thompson (The_Other_Keit h) 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
4013
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 than the one I think he will provide. The test data, A:\\"514650.txt", appears at the end of the program. The problem is that the program won't read this file and the debugger as far as i know how to work it won't point out the mistake of any....
3
19778
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 XML file really needs to contain some text like: "&#x3;&#x4;&#x14;&#x8;&#x8;"? (as content of a tag) The story is: I am writing a program to parse some XML files from another program. In that program, it graps webpages, and saves the pages'...
4
4951
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 like n = ((n - k) % length + length) % length where as in e.g. Pascal i can simply write
24
2135
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 different
1
2761
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
1945
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 m,n,p,q,i,j,k;
2
29693
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
3874
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 How to make it compile? I also tried buf but that gives "segmentation fault". Thanks in advanced.
3
2612
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
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.