unsigned/signed mismatch in MSC 6.0

Kevin Schmidt schmidt at mars.jpl.nasa.gov
Wed Nov 14 10:56:54 AEST 1990


In article <2301 at sparko.gwu.edu> timur at 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)<WIDTH
>
>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 at mars.jpl.nasa.gov
      / / / /_/ / / /   | Jet Propulsion Laboratory | schmidt at jems.jpl.nasa.gov
 _   / / / ____/ / /    | 4800 Oak Grove Dr.        |
/ /_/ / / /     / /___  | M/S 301-355               |
\____/ /_/     /______/ | Pasadena, CA  91109       |



More information about the Comp.lang.c mailing list