473,657 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

invalid operands to binary == or wrong type argument to unary exclamation mark

Hi Everyone,

I have defined a function:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv);

and in the code:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv) {

snip

if(hdfdata != NULL) free(hdfdata);
return retv;
fail:
if(hdfdata != NULL) free(hdfdata);
exit(EXIT_FAILU RE);
}

called the function like this:

if (arrFromHdfNode (nodelist,retv) == NULL) {
fprintf(stderr, "Failed getting data\n");
goto fail;

or like this

if (!(arrFromHdfNo de(nodelist,ret v))) {
fprintf(stderr, "Failed getting data\n");
goto fail;

The functions should return a struct or exit(EXIT_FAILU RE) if
something went wrong.

For the first call I got the error:
error: invalid operands to binary ==
and for the second I got:
error: wrong type argument to unary exclamation mark

Can someone point me in the right direction? What is going on here?

Thanks in advance,
/S

Nov 6 '07 #1
5 7114
On Tuesday 06 Nov 2007 3:45 pm Sheldon <sh******@gmail .comwrote in
article <11************ **********@o38g 2000hse.googleg roups.com>:
Hi Everyone,

I have defined a function:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv);

and in the code:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv) {

snip

if(hdfdata != NULL) free(hdfdata);
return retv;
fail:
if(hdfdata != NULL) free(hdfdata);
exit(EXIT_FAILU RE);
}

called the function like this:

if (arrFromHdfNode (nodelist,retv) == NULL) {
fprintf(stderr, "Failed getting data\n");
goto fail;

or like this

if (!(arrFromHdfNo de(nodelist,ret v))) {
fprintf(stderr, "Failed getting data\n");
goto fail;

The functions should return a struct or exit(EXIT_FAILU RE) if
something went wrong.

For the first call I got the error:
error: invalid operands to binary ==
and for the second I got:
error: wrong type argument to unary exclamation mark

Can someone point me in the right direction? What is going on here?
The function is defined as returning a struct Transient type object.
NULL is a pointer constant value. Both are not directly comparable. One
possibility is for the function to return a pointer to struct Transient
and return a null pointer value on error.

Similarly the ! operand accepts only a scalar type. A struct object is
not a scalar type. Again returning a pointer to that struct type would
solve this problem.

Nov 6 '07 #2
Sheldon said:
Hi Everyone,

I have defined a function:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv);

and in the code:

struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv) {

snip

if(hdfdata != NULL) free(hdfdata);
return retv;
That's an unconditional return, and you're not in a loop or anything like
that. So everything from here to the end of that function is unreachable
code.
fail:
You don't use this.
if(hdfdata != NULL) free(hdfdata);
exit(EXIT_FAILU RE);
}

called the function like this:

if (arrFromHdfNode (nodelist,retv) == NULL) {
But arrFromHdfNode returns a struct, not a pointer. C doesn't allow you to
use the == operator to compare structs, so you can't have a struct as one
of the operands, and the value returned by arrFromHdfNode( nodelist, retv)
has struct type, and that's why you're getting your error.
fprintf(stderr, "Failed getting data\n");
goto fail;
You're trying to use goto to jump from one function to a label in another
function. Again, this is against the rules of C.
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 6 '07 #3
On 6 Nov, 11:25, Richard Heathfield <r...@see.sig.i nvalidwrote:
Sheldon said:


Hi Everyone,
I have defined a function:
struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv);
and in the code:
struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv) {
snip
if(hdfdata != NULL) free(hdfdata);
return retv;

That's an unconditional return, and you're not in a loop or anything like
that. So everything from here to the end of that function is unreachable
code.
fail:

You don't use this.
if(hdfdata != NULL) free(hdfdata);
exit(EXIT_FAILU RE);
}
called the function like this:
if (arrFromHdfNode (nodelist,retv) == NULL) {

But arrFromHdfNode returns a struct, not a pointer. C doesn't allow you to
use the == operator to compare structs, so you can't have a struct asone
of the operands, and the value returned by arrFromHdfNode( nodelist, retv)
has struct type, and that's why you're getting your error.
fprintf(stderr, "Failed getting data\n");
goto fail;

You're trying to use goto to jump from one function to a label in another
function. Again, this is against the rules of C.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999- Dölj citerad text -

- Visa citerad text -
Thanks! Will redo the code accordingly.

/S

Nov 6 '07 #4
On 6 Nov, 11:22, santosh <santosh....@gm ail.comwrote:
On Tuesday 06 Nov 2007 3:45 pm Sheldon <shejo...@gmail .comwrote in
article <1194344102.049 441.174...@o38g 2000hse.googleg roups.com>:


Hi Everyone,
I have defined a function:
struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv);
and in the code:
struct Transient arrFromHdfNode( HL_NodeList *nodelist, struct
Transient retv) {
snip
if(hdfdata != NULL) free(hdfdata);
return retv;
fail:
if(hdfdata != NULL) free(hdfdata);
exit(EXIT_FAILU RE);
}
called the function like this:
if (arrFromHdfNode (nodelist,retv) == NULL) {
fprintf(stderr, "Failed getting data\n");
goto fail;
or like this
if (!(arrFromHdfNo de(nodelist,ret v))) {
fprintf(stderr, "Failed getting data\n");
goto fail;
The functions should return a struct or exit(EXIT_FAILU RE) if
something went wrong.
For the first call I got the error:
error: invalid operands to binary ==
and for the second I got:
error: wrong type argument to unary exclamation mark
Can someone point me in the right direction? What is going on here?

The function is defined as returning a struct Transient type object.
NULL is a pointer constant value. Both are not directly comparable. One
possibility is for the function to return a pointer to struct Transient
and return a null pointer value on error.

Similarly the ! operand accepts only a scalar type. A struct object is
not a scalar type. Again returning a pointer to that struct type would
solve this problem.- Dölj citerad text -

- Visa citerad text -
Thanks! Will redo the code accordingly.

/S

Nov 6 '07 #5
Richard wrote:
) Sheldon said:
)snip
)>
) if(hdfdata != NULL) free(hdfdata);
) return retv;
)
) That's an unconditional return, and you're not in a loop or anything like
) that. So everything from here to the end of that function is unreachable
) code.
)
) fail:
)
) You don't use this.

Isn't that right there a label you can goto ?

) if(hdfdata != NULL) free(hdfdata);
) exit(EXIT_FAILU RE);
)}
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Nov 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3634
by: Guy | last post by:
I'd like so that when a user moves there mouse over an image (or clicks the image, either way it doesn't matter), I'd like some text to appear. I was going to use the img tag with the alt parameter but the text is a few sentences long and the yellowish box doesn't stay up long enough to read the whole thing? Is there a way to keep the yellowish box there until the use moves his mouse away, or to keep the box there for maybe 10 seconds or...
2
1648
by: DraguVaso | last post by:
Hi, I have a DataGrid bound to an sqlDataAdapter. When I do a SqlDataAdapter.Update, on 1 row I got a red dot with a whie exclamation mark in it, to show me there is an error, and the changes aren't saved. The problem is that I'm not able to knwo what error it is, I just get the red cirkel with the white exclamation mark before my row. Does anybody know how to get the reason of that error?
4
31379
by: muthu | last post by:
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 */
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 ) ....
11
16917
by: Spiros Bousbouras | last post by:
#include <stdlib.h> int main(void) { char **p1 ; const char **p2 ; p1 = malloc(5 * sizeof(char *)) ; if (p1 == 0) return EXIT_FAILURE ; p2 = p1 + 1 ; p2 - p1 ;
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;
1
1372
by: =?Utf-8?B?VE1D?= | last post by:
Hello, I am running XP with windows firewall, I can sign in to WLM with no problem but cannot contact any contacts or send emails. It say's there offline and tells them I am offline. I can receive emails and there is no error code, but when I go to connections in wlm there is an exclamation mark on the connection status computer side. I changed the settings through my firewall, explorer and wlm with no luck. I know it is something simple,...
2
4987
by: Tyler Palmer | last post by:
I am having a problem with my program. I cant figure out a solution for the compiler error im getting. In function `double endingConversion(double)': invalid operands of types `double ()(double)' and `double' to binary `operator*' Please Help thanks. #include <iostream> #include <iomanip> #include <cmath>
0
8324
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
8842
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
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.