473,232 Members | 1,593 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,232 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 14582
"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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.