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? 3 6412
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
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]$
On Sep 13, 1:56 am, john <j...@no.spamwr ote:
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 objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 answer here? If a is converted to unsigned, then b>a.
But, if b is converted to signed,then a>b. What's the correct coversion
(what is the compiler supposed to do?)
|
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. The reference should be 3.9.1
(Fundamental types), and 4.7 (Integral conversions).
It seems to me that the Standard doesn't specify:
1) The "value representation" of any of these types, except that (3.9.1/3)
"... The range of nonnegative...
|
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 standard doesn't even care what a normal char
is (because signed and unsigned have equal behavior).
For example if someone does this:
unsigned char a = -2; /* or = 254 */
|
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 set?
Thank you.
-- Srinivasan.
|
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> as I would expect:
template<class T> void f(T t)
{
}
template<> void f<char>(char t)
{
| |
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.
unsigned char n;
// fill array with numeric and unicode text data
wchar_t *test;
test = &n; // this doesn't work
test = &(wchar_t)n; // this doesn't work
test = &((wchar_t)n); // this doesn't work
test = (wchar_t)&n; // this doesn't work
|
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
signed/unsigned modifier to class declarations
to next revision of C++ programming language
|
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
involved. The problem
is that comparisons between signed and unsigned values are machine-
dependent, because
they depend on the sizes of the various integer types. For example,
suppose that int is 16 bits
|
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 vaguely . Can
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |