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