Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!mars!schmidt From: schmidt@mars.jpl.nasa.gov (Kevin Schmidt) Newsgroups: comp.lang.c Subject: Re: unsigned/signed mismatch in MSC 6.0 Message-ID: <1990Nov13.235654.15498@jato.jpl.nasa.gov> Date: 13 Nov 90 23:56:54 GMT References: <2301@sparko.gwu.edu> Sender: news@jato.jpl.nasa.gov Reply-To: schmidt@mars.UUCP (Kevin Schmidt) Organization: Jet Propulsion Laboratory, Pasadena, CA. Lines: 26 Nntp-Posting-Host: mars.jpl.nasa.gov In article <2301@sparko.gwu.edu> timur@seas.gwu.edu () writes: >I'm using Microsoft C 6.0, and I have my warnings set to level 4. I'm >getting an error with this expression: > >strlen(s) >where WIDTH is defined as some expression including an integer. I don't >exactly understand the error I get (C4018 '<' : signed/unsigned mismatch), >but it looks as if it knows that WIDTH is a signed integer and strlen() >returns an unsigned, and the two don't match. The problem is that WIDTH >uses an integer variable from an include file which I can't modify. > Instead of casting the expression in the #define, cast it when you use it. i.e. strlen(s) < (unsigned)WIDTH This should fix your warning. _______________________________________________________________________________ _ ____ _ | | / / / _ \ / / | Kevin T. Schmidt | schmidt@mars.jpl.nasa.gov / / / /_/ / / / | Jet Propulsion Laboratory | schmidt@jems.jpl.nasa.gov _ / / / ____/ / / | 4800 Oak Grove Dr. | / /_/ / / / / /___ | M/S 301-355 | \____/ /_/ /______/ | Pasadena, CA 91109 |