I'm having hard time understanding nature of issue I encountered in my code. Line
if ((struct.c == 0x02) && (struct2.c == 0x02) && (struct.s == !struct2.s))
{/**/}
where c
is int
and s
is uint64_t
produces
C4388:'==' signed/unsigned mismatch
warning. I understand what that warning is, I can't see what is triggering it here. What am I missing?
Directly quoting the
C11
standard, chapter §6.5.3.3, (emphasis mine)So, the result of the logical
!
operator isint
, so!struct2.s
producesint
value, and the expressioncreates the issue.
NOTE 1:
I guess you use
struct
as a structure name just for illustration purpose, otherwise,struct
being a reserved keyword inC
you cannot use that as a variable name.NOTE 2:
Maybe what you actually meant is
(struct.s != struct2.s)
, but that's also just a (probable)guess.FOOTNOTE :: Earlier question tagged C++ also, Moving it as footnote but keeping the info just for reference.
Regarding
C++
, the return type of!
isbool
. Ref:C++11
, chapter § 5.3.3 (again, emphasis mine)