delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/29/14:36:45

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q]: unsigned char
Date: Wed, 29 Oct 1997 08:50:20 -0800
Organization: Alcyone Systems
Lines: 42
Message-ID: <3457694C.56DACF92@alcyone.com>
References: <ABktjLqSgI AT rsuzi DOT pgu DOT karelia DOT ru>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Roman Suzi wrote:

> >I think you are missing the fact that '\xFD' is NOT a character
> > constant,
> >it's an int.  Therefore, -funsigned-char doesn't affect it.
> 
>    NO!!! It has sizeof('\xFD') == 1
> 
> I have just checked it.

Then you must be using C++ instead of C.  In C, a character constant is
of type int, not char.

>    Possibly, the fact, that my file is probe.cc
> and not probe.c ?

Yep, C++ and not C.

> >If you want avoid trouble always use explicit casts in these cases.
>  --  Then the program will be a nightmare...
> 
> OK. I can use:
> 
> #define UC (unsigned char)
> 
> ..
> 
> c = UC'\xFD'
> 
> No problem here.

There's little worse than making #defines so that C/C++ looks like a
different language.  Don't be such a baby -- writing explicit casts that
are clear and unambiguous is a sign of _good_ programming.

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                     \
  "After each war there is a little / less democracy to save."
                                   / Brooks Atkinson

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019