unsigned/signed mismatch in MSC 6.0

The Time Traveler timur at seas.gwu.edu
Sun Nov 4 08:59:01 AEST 1990


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.

So basically, WIDTH is a signed expression while strlen() is unsigned,
and the compiler doesn't like it.  Is there anyway I can define WIDTH as
unsigned even though it uses a signed expression?

#define WIDTH (COLS/3)

COLS is defined as an integer in the dCURSES library.   I've tried stuff
like

#define WIDTH (unsigned(COLS)/3)

but that causes weird errors elsewhere.  Thanx in advance!

Timur

------------------------------------------------------------ The Time Traveler
Your daddy works in porno
Now that mommy's not around                                 timur at seas.gwu.edu
She used to love her heroin                               HE891C at GWUVM.GWU.EDU
But now she's underground              - Guns N' Roses



More information about the Comp.lang.c mailing list