473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

signed/unsigned wchar_t

As far as I know there is only the type wchar_t. However my compiler
compiles both "signed wchar_t" and "unsigned wchar_t".

Are there both signed and unsigned wchar_t types?
Sep 12 '07 #1
3 6377
john wrote:
As far as I know there is only the type wchar_t. However my compiler
compiles both "signed wchar_t" and "unsigned wchar_t".

Are there both signed and unsigned wchar_t types?
It is unspecified (or, probably, implementation-defined, but I did
not find the exact place) whether 'wchar_t' is signed or unsigned,
and what would happen if you apply 'signed' to it. What I've found
is that 'wchar_t' has an *underlying* integral type, and that the
specifier "signed" is superfluous with integral types. Whether it
is legal to specify 'wchar_t' as "unsigned" I am not sure.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 12 '07 #2
Victor Bazarov wrote:
john wrote:
>As far as I know there is only the type wchar_t. However my compiler
compiles both "signed wchar_t" and "unsigned wchar_t".

Are there both signed and unsigned wchar_t types?

It is unspecified (or, probably, implementation-defined, but I did
not find the exact place) whether 'wchar_t' is signed or unsigned,
and what would happen if you apply 'signed' to it. What I've found
is that 'wchar_t' has an *underlying* integral type, and that the
specifier "signed" is superfluous with integral types. Whether it
is legal to specify 'wchar_t' as "unsigned" I am not sure.

V

The code

int main()
{
signed wchar_t c;
}

produces in my compiler:
[john@localhost extract]$ g++ temp.cpp -o temp

[john@localhost extract]$ g++ -ansi temp.cpp -o temp

[john@localhost extract]$ g++ -ansi -pedantic-errors temp.cpp -o temp
temp.cpp: In function ‘int main()’:
temp.cpp:3: error: long, short, signed or unsigned used invalidly for ‘c’

[john@localhost extract]$
Sep 13 '07 #3
On Sep 13, 1:56 am, john <j...@no.spamwrote:
Victor Bazarov wrote:
john wrote:
As far as I know there is only the type wchar_t. However my compiler
compiles both "signed wchar_t" and "unsigned wchar_t".
Are there both signed and unsigned wchar_t types?
It is unspecified (or, probably, implementation-defined, but I did
not find the exact place) whether 'wchar_t' is signed or unsigned,
and what would happen if you apply 'signed' to it. What I've found
is that 'wchar_t' has an *underlying* integral type, and that the
specifier "signed" is superfluous with integral types. Whether it
is legal to specify 'wchar_t' as "unsigned" I am not sure.
It's illegal, although it is interesting that the standard feels
it necessary to say explicitly that "there are no signed,
unsigned, short, or long bool types or values" but doesn't feel
the need to be this explicit about wchar_t.
The code
int main()
{
signed wchar_t c;
}
produces in my compiler:
[john@localhost extract]$ g++ temp.cpp -o temp
[john@localhost extract]$ g++ -ansi temp.cpp -o temp
[john@localhost extract]$ g++ -ansi -pedantic-errors temp.cpp -o temp
temp.cpp: In function ?int main()?:
temp.cpp:3: error: long, short, signed or unsigned used invalidly for ?c?
Which rather answers the question, doesn't it? If something
compiles with plain g++, and not with g++ -std=c++98 -pedantic,
then it's obviously a g++ extension.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Sep 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: MiniDisc_2k2 | last post by:
Okay, here's a question about the standard. What does it say about unsigned/signed mismatches in a comparison statement: char a = 3; unsigned char b = 255; if (a<b) Now what's the real...
8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
4
by: Sriniv | last post by:
Hello all, Do we have unsigned and signed char types? If so, i'd like to know the differences between the two. And one more question. Is there any provision in C for using the Unicode character...
8
by: Marcin Kalicinski | last post by:
Are 3 types: signed char, char and unsigned char distinct? My compiler is treating char as signed char (i.e. it has sign, and range from -128 to 127), but the following code does not call f<char>...
2
by: brimp | last post by:
I have an array of bytes that has data loaded into it. I want to get a wchar_t pointer to the data loaded as unicode characters so I can use unicode string functions. I'm not sure how to do it. ...
10
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
6
by: Kislay | last post by:
Consider the following code snippet unsigned int i=10; int j= - 2; // minus 2 if(i>j) cout<<"i is greater"; else cout<<"j is greater"; Since i is unsigned , j is greater . I know why , but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.