473,378 Members | 1,377 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,378 software developers and data experts.

wchar_t

Hello,

does anyone know which layer is responsible for defining the size of
wchar_t?

Naturally enough, it's not defined in the language. I looked in the
SystemV processor supplement and the Itanium C++ ABI which are
authorative for my platform, but there is no mentioning of this.

The manual of the compiler I'm using, gcc, doesn't tell me either.

Does anyone know more?

Cheers,

Jens
Sep 27 '06 #1
12 14601
"Jens Theisen" <jt***@arcor.dewrote in message
news:87************@arcor.de...
does anyone know which layer is responsible for defining the size of
wchar_t?

Naturally enough, it's not defined in the language.
Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Sep 28 '06 #2

P.J. Plauger wrote:
"Jens Theisen" <jt***@arcor.dewrote in message
news:87************@arcor.de...
does anyone know which layer is responsible for defining the size of
wchar_t?

Naturally enough, it's not defined in the language.

Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.
The part that does not seem natural to me is the name "wchar_t". We
don't have types "int_t", "char_t", "bool_t", etc. I'm sure there is a
good reason for "wchar_t" instead of "wchar", but that doesn't mean it
isn't still ugly.

--
Alan Johnson

Sep 28 '06 #3
Alan Johnson wrote:
P.J. Plauger wrote:
>"Jens Theisen" <jt***@arcor.dewrote in message
news:87************@arcor.de...
>>does anyone know which layer is responsible for defining the size of
wchar_t?

Naturally enough, it's not defined in the language.
Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.

The part that does not seem natural to me is the name "wchar_t". We
don't have types "int_t", "char_t", "bool_t", etc. I'm sure there is a
good reason for "wchar_t" instead of "wchar", but that doesn't mean it
isn't still ugly.
Because it is a typedef, rather than a built-in native type.(?)
That puts it in the same category as 'int16_t', 'int32_t', etc
from 'stdint.h', size_t, fpos_t, ptrdiff_t, etc, etc.
Sep 28 '06 #4

Larry Smith wrote:
Alan Johnson wrote:
P.J. Plauger wrote:
"Jens Theisen" <jt***@arcor.dewrote in message
news:87************@arcor.de...

does anyone know which layer is responsible for defining the size of
wchar_t?

Naturally enough, it's not defined in the language.
Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.
The part that does not seem natural to me is the name "wchar_t". We
don't have types "int_t", "char_t", "bool_t", etc. I'm sure there is a
good reason for "wchar_t" instead of "wchar", but that doesn't mean it
isn't still ugly.

Because it is a typedef, rather than a built-in native type.(?)
That puts it in the same category as 'int16_t', 'int32_t', etc
from 'stdint.h', size_t, fpos_t, ptrdiff_t, etc, etc.
According to 2.11.1 wchar_t is a keyword. It has the restriction that
it must have the same storage and alignment requirements as some other
integral type, like it would if it were a typedef, but it is in fact a
first class type.

--
Alan Johnson

Sep 28 '06 #5
In article <RGFSg.3421$Kw1.2848@trnddc05>, ls****@nospam.com says...

[ ... why 'wchar_t' instead of 'wchar' ?]
Because it is a typedef, rather than a built-in native type.(?)
That puts it in the same category as 'int16_t', 'int32_t', etc
from 'stdint.h', size_t, fpos_t, ptrdiff_t, etc, etc.
In C++, it's a native type -- but when originally devised as part of the
C89 standard, it was a typedef.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sep 28 '06 #6
Alan Johnson wrote:
The part that does not seem natural to me is the name "wchar_t". We
don't have types "int_t", "char_t", "bool_t", etc. I'm sure there is a
good reason for "wchar_t" instead of "wchar", but that doesn't mean it
isn't still ugly.
It's because it came relatively later in the history of C and C++.
In C it is a typedef typically. In C++ in needs to be a real type.
Sep 28 '06 #7
"P.J. Plauger" <pj*@dinkumware.comwrites:
Naturally enough, it's not defined in the language.

Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.
I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.

Regards,

Jens
Sep 28 '06 #8

Jens Theisen wrote:
"P.J. Plauger" <pj*@dinkumware.comwrites:
Naturally enough, it's not defined in the language.
Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.

I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.
3.9.1/5
Type wchar_t is a distinct type whose values can represent distinct
codes for all members of the largest extended character set specified
among the supported locales (22.1.1). Type wchar_t shall have the same
size, signedness, and alignment requirements (3.9) as one of the other
integral types, called its underlying type.

So, just like any other integral type, if you want to know the actual
size in your implementation, you need to consult your implementation.
sizeof L'x' is one easy way to do that. The answer may be different for
diifferent implementations.

Gavin Deane

Sep 29 '06 #9
Gavin Deane wrote:
Jens Theisen wrote:
>"P.J. Plauger" <pj*@dinkumware.comwrites:
>>>Naturally enough, it's not defined in the language.

Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.

I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.

3.9.1/5
Type wchar_t is a distinct type whose values can represent distinct
codes for all members of the largest extended character set specified
among the supported locales (22.1.1). Type wchar_t shall have the same
size, signedness, and alignment requirements (3.9) as one of the other
integral types, called its underlying type.

So, just like any other integral type, if you want to know the actual
size in your implementation, you need to consult your implementation.
sizeof L'x' is one easy way to do that. The answer may be different
for diifferent implementations.
I'd probably use 'std::numeric_limits<wchar_t>' or traits template
specialised on 'wchar_t' to find out more about it, not 'sizeof'.
After all, sizeof(int), sizeof(unsigned), sizeof(long) and sizeof(
unsigned long), are all the same on many 32-bit platforms I know.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 29 '06 #10
"Gavin Deane" <de*********@hotmail.comwrites:
So, just like any other integral type, if you want to know the actual
size in your implementation [...]
I quote from my last posting:
I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.
You just told me that's it's not defined in the language:
>, you need to consult your implementation.
sizeof L'x' is one easy way to do that. The answer may be different for
diifferent implementations.
something which I have already stated in my first posting!

Regards,

Jens
Sep 29 '06 #11
"Jens Theisen" <jt***@arcor.dewrote in message
news:87************@arcor.de...
"P.J. Plauger" <pj*@dinkumware.comwrites:
Naturally enough, it's not defined in the language.

Naturally enough, it is. L'x' has type wchar_t, so sizeof L'x'
tells you the size of wchar_t.

I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.
What you said was:

: does anyone know which layer is responsible for defining the size of
: wchar_t?
:
: Naturally enough, it's not defined in the language.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Sep 30 '06 #12

Jens Theisen wrote:
"Gavin Deane" <de*********@hotmail.comwrites:
So, just like any other integral type, if you want to know the actual
size in your implementation [...]

I quote from my last posting:
I think I was quite explicit in my posting that I'm not wondering
about how big it is, but where it's defined.

You just told me that's it's not defined in the language:
, you need to consult your implementation.
sizeof L'x' is one easy way to do that. The answer may be different for
diifferent implementations.

something which I have already stated in my first posting!
So you already knew that the language does not specify the exact number
of bits or bytes or octets or whatever in a wchar_t. And you already
know that this implies that the size of wchar_t might be different in
different implementations of the language. Since the suggestion that
one way of finding out the size of wchar_t in your implementation is to
do sizeof L'x' didn't seem to satisfy you, you presumably aren't asking
"How do I find out the size of wchar_t in my implementation?"

You originally asked "does anyone know which layer is responsible for
defining the size of
wchar_t?". I don't know what that question means. What do you mean by
"layer"? The only sensible question I can think of in this context is,
"How do I find out the size of wchar_t in my implementation?". So when
I read your post, I couldn't understand your question as you wrote it,
but I assumed you were asking "How do I find out the size of wchar_t in
my implementation?" because that is the only question I could think
that you might be trying to ask.

Is that your question? Or is it something else? Or has it been answered
already?

Gavin Deane

Sep 30 '06 #13

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

Similar topics

3
by: Julius Mong | last post by:
Hi all, I'm doing this: // Test char code wchar_t lookup = {0x8364, 0x5543, 0x3432, 0xabcd, 0xef01}; for (int x=0; x<5; x++) { wchar_t * string = (wchar_t*) malloc(sizeof(wchar_t)); string =...
1
by: Mark Fancy | last post by:
I have a project that I'm trying to get to compile. I need to have the /Tc:wchar_t compile switch in order to use some libraries. I have included the following header files: #include <mapix.h>...
23
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString,...
1
by: jjf | last post by:
Do Standard C's wide characters and wide strings require absolutely that each character be stored in a single wchar_t, or can characters be "multi-wchar_t" in the same way that they can be...
8
by: Rui Maciel | last post by:
I've just started learning how to use the wchar_t data type as the basis for Unicode strings and unfortunately I'm having quite a bit of problems, both in the C front and the Unicode front. In...
3
by: john | last post by:
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?
16
by: Michael Brennan | last post by:
I guess this question only applies to programming applications for UNIX, Windows and similiar. If one develops something for an embedded system I can understand that wchar_t would be unnecessary. ...
5
by: yakir22 | last post by:
Hello experts, I am dealing now in porting our server from windows to linux. our client is running only on windows machine. to avoid the wchar_t size problem ( in windows its 2 bytes and linux is...
5
by: Samant.Trupti | last post by:
Hi, There is one thing I am cofused about.... If I have a declareation say char str; Now if I want to change it to wchar so do I have to change it like .... wchar_t str; or double the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.