Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #43249

Re: wchar_t: signed or unsigned?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: wchar_t: signed or unsigned?
Date 2014-04-21 15:13 -0400
Organization Self
Message-ID <53556DF1.9080809@verizon.net> (permalink)
References <4cial9tecgiks7ov2q3c1oo53492kvf3ti@4ax.com> <lj3mpr$dml$1@usenet.stanford.edu> <lnwqeizgkf.fsf@nuthaus.mib.org> <lj3pmu$eqa$1@usenet.stanford.edu>

Show all headers | View raw


On 04/21/2014 02:57 PM, Seungbeom Kim wrote:
> On 2014-04-21 11:24, Keith Thompson wrote:
>> Seungbeom Kim <musiphil@bawi.org> writes:
>>> You can test it with WCHAR_MIN (defined in <stdint.h>): it shall
>>> be <= -127 if wchar_t is signed, and 0 if wchar_t is unsigned.
>>>
>>>> Or is it one of those things left up to the compiler writer?
>>>
>>> Yes.
>>> I don't see it mentioned even as implementation-defined;
>>> I think it is unspecified.
>>
>> It's implementation-defined.
>>
>> The values of WCHAR_MIN and WCHAR_MAX, macros defined in <stdint.h>, are
>> explicitly implementation-defined (which means that the implementation
>> must document them).
>>
>> See N1570 7.20.3.
> 
> Where do you think I got the requirement about WCHAR_MIN quoted above? :)
> 
> I knew the limit values were implementation-defined, but didn't see
> anything about the signedness of wchar_t itself, and didn't know
> the implementation-definedness could be applied transitively.

There's a standard-defined link between the implementation-defined
values and the signedness of the type: "If wchar_t (see 7.19) is defined
as a signed integer type, the value of WCHAR_MIN shall be no greater
than −127 and the value of WCHAR_MAX shall be no less than 127;
otherwise, wchar_t is defined as an unsigned integer type, and the value
of WCHAR_MIN shall be 0 and the value of WCHAR_MAX shall be no less than
255." (7.20.3p4)
A conforming implementation is not required to document the signedness
of wchar_t, but that signedness can be determined, with a certainty,
from the value of WCHAR_MIN, which must be documented.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

wchar_t: signed or unsigned? DSF <notavalid@address.here> - 2014-04-21 12:55 -0400
  Re: wchar_t: signed or unsigned? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2014-04-21 20:02 +0200
  Re: wchar_t: signed or unsigned? Seungbeom Kim <musiphil@bawi.org> - 2014-04-21 11:07 -0700
    Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-21 11:24 -0700
      Re: wchar_t: signed or unsigned? Seungbeom Kim <musiphil@bawi.org> - 2014-04-21 11:57 -0700
        Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 15:13 -0400
  Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 14:31 -0400
  Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-21 15:28 -0500
    Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 16:48 -0400
      Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-21 14:08 -0700
  Re: wchar_t: signed or unsigned? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-22 03:21 -0700
    Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-22 10:48 -0500
    Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-22 09:10 -0700
  Re: wchar_t: signed or unsigned? gordonb.8ql82@burditt.org (Gordon Burditt) - 2014-04-23 03:31 -0500
    Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-25 10:00 -0500
      Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-25 09:00 -0700
        Re: wchar_t: signed or unsigned? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-25 10:27 -0700
        Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-25 16:43 -0500

csiph-web