Hello everyone,


1.

I am developing for both x86 and x64. I stop mouse on size_t in the code,
and "typedef unsigned int size_t" is always displayed. I think it is not
correct for x64. Since x64 size_t is 64-bit and unsigned int on x64 is
32-bit. So, the first question is how to let mouse display the correct
typedef?

2.

But when I select size_t and click go to Definition/Declaration, but always
failed. Where are they defined?


thanks in advance,
George

Re: size_t by Doug

Doug
Fri Oct 10 10:19:54 CDT 2008

On Fri, 10 Oct 2008 01:07:00 -0700, George
<George@discussions.microsoft.com> wrote:

>Hello everyone,
>
>
>1.
>
>I am developing for both x86 and x64. I stop mouse on size_t in the code,
>and "typedef unsigned int size_t" is always displayed. I think it is not
>correct for x64. Since x64 size_t is 64-bit and unsigned int on x64 is
>32-bit. So, the first question is how to let mouse display the correct
>typedef?

You're not going to find some IDE setting called "Display correct typedefs
in tooltips." If you want to report the bug, you can do so here:

http://connect.microsoft.com/feedback/default.aspx?SiteID=210

>2.
>
>But when I select size_t and click go to Definition/Declaration, but always
>failed. Where are they defined?

Try to compile this fragment:

size_t x;

Last time I checked, it will compile, because VC makes size_t an intrinsic
type. This is a (minor) deviation from the standard, which requires size_t
to be a typedef defined in various header files.

--
Doug Harrison
Visual C++ MVP

Re: size_t by Bo

Bo
Fri Oct 10 11:03:40 CDT 2008

Doug Harrison [MVP] wrote:
> On Fri, 10 Oct 2008 01:07:00 -0700, George
> <George@discussions.microsoft.com> wrote:
>
>> Hello everyone,
>>
>>
>> 1.
>>
>> I am developing for both x86 and x64. I stop mouse on size_t in
>> the code, and "typedef unsigned int size_t" is always displayed. I
>> think it is not correct for x64. Since x64 size_t is 64-bit and
>> unsigned int on x64 is 32-bit. So, the first question is how to
>> let mouse display the correct typedef?
>
> You're not going to find some IDE setting called "Display correct
> typedefs in tooltips." If you want to report the bug, you can do so
> here:
>
> http://connect.microsoft.com/feedback/default.aspx?SiteID=210
>
>> 2.
>>
>> But when I select size_t and click go to Definition/Declaration,
>> but always failed. Where are they defined?
>
> Try to compile this fragment:
>
> size_t x;
>
> Last time I checked, it will compile, because VC makes size_t an
> intrinsic type. This is a (minor) deviation from the standard,
> which requires size_t to be a typedef defined in various header
> files.

It is defined in the required headers (which George perhaps forgot to
include? :-), but as it is also the return type of the sizeof
operator, the compiler will have to know about it anyway. That's a
quirk of the language!


Bo Persson



Re: size_t by Tim

Tim
Fri Oct 10 23:42:27 CDT 2008

George <George@discussions.microsoft.com> wrote:
>
>1.
>
>I am developing for both x86 and x64. I stop mouse on size_t in the code,
>and "typedef unsigned int size_t" is always displayed. I think it is not
>correct for x64. Since x64 size_t is 64-bit and unsigned int on x64 is
>32-bit. So, the first question is how to let mouse display the correct
>typedef?
>
>2.
>
>But when I select size_t and click go to Definition/Declaration, but always
>failed. Where are they defined?

Windows comes with an excellent search tool
You must learn to use the search tools yourself.
findstr typedef.*size_t *.h

You'll find this in crtdefs.h:

#ifndef _SIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#define _SIZE_T_DEFINED
#endif
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: size_t by George

George
Sat Oct 11 04:11:01 CDT 2008

Thanks Doug,


1. Do you think it is an IDE bug to prevent mouse to show the correct
definition and also go to the wrong definition of 32-bit when developing
64-bit application?

2. I have tried without any header files, size_t x will compile. It proves
size_t is a built-in type? But I searched MSDN never mentions this and never
describes size_t is for 32-bit for x86 and 64-bit for x64.


regards,
George

Re: size_t by George

George
Sat Oct 11 04:14:00 CDT 2008

Hi Tim,


How do you prove size_t is using definitions in crtdefs.h? I have tried
without any header files included, size_t x could compile. Any comments?


regards,
George

Re: size_t by George

George
Sat Oct 11 04:25:01 CDT 2008

Hi Bo Persson,


I am confused about your comments. Do you mean we need include some header
file to use size_t or not? From testing, seems we do not need to include any
header file in order to use size_t.

My test environment, VC 2008.


regards,
George

Re: size_t by Bo

Bo
Sat Oct 11 04:34:18 CDT 2008

George wrote:
> Hi Bo Persson,
>
>
> I am confused about your comments. Do you mean we need include some
> header file to use size_t or not? From testing, seems we do not
> need to include any header file in order to use size_t.

We need to include a header to get access to size_t, because it is a
typedef.

>
> My test environment, VC 2008.

VC2008 knows about size_t even without a header, because the compiler
uses the type itself. When you use it, you should include the
appropriate header.


Bo Persson




Re: size_t by George

George
Sat Oct 11 05:21:00 CDT 2008

Thanks Bo Persson,


I understand your point is size_t is actually defined in some header, not
built in type, correct?

If so, which header file defines it? I actually find a couple of definitions
when do a search for size_t typedef.


regards,
George

Re: size_t by Bo

Bo
Sat Oct 11 06:31:04 CDT 2008

George wrote:
> Thanks Bo Persson,
>
>
> I understand your point is size_t is actually defined in some
> header, not built in type, correct?
>
> If so, which header file defines it? I actually find a couple of
> definitions when do a search for size_t typedef.
>

That's a remnant from the C language. In C, one library header is not
allowed to include any other, so some things like size_t and NULL are
defined several times.

Just pick one!


Bo Persson



Re: size_t by George

George
Sat Oct 11 07:01:01 CDT 2008

Thanks Bo Persson,


1.

> That's a remnant from the C language. In C, one library header is not
> allowed to include any other, so some things like size_t and NULL are
> defined several times.

I am not quite sure what do you mean library header? .h file or? Could you
show me a sample which means "one library header is not allowed to include
any other" please?

2.

It is fine if there is multiple definitions because of the limitation of C
itself as you mentioned, but how to find which definition is the one I am
currently using?


regards,
George

Re: size_t by Bo

Bo
Sat Oct 11 09:04:41 CDT 2008

George wrote:
> Thanks Bo Persson,
>
>
> 1.
>
>> That's a remnant from the C language. In C, one library header is
>> not allowed to include any other, so some things like size_t and
>> NULL are defined several times.
>
> I am not quite sure what do you mean library header? .h file or?

Yes, standard .h files provided with the C compiler.


> Could you show me a sample which means "one library header is not
> allowed to include any other" please?
>
> 2.
>
> It is fine if there is multiple definitions because of the
> limitation of C itself as you mentioned, but how to find which
> definition is the one I am currently using?

They are required to be identical, so you have to worry. In C
"stddef.h" is a good choice to standard typedefs, like size_t or NULL.
In C++ you could use <cstddef> instead.

If you use Visual Studio, just type size_t and press F1. The help page
will tell you.


Bo Persson



Re: size_t by Bo

Bo
Sat Oct 11 14:48:08 CDT 2008

Bo Persson wrote:
> George wrote:
>> Thanks Bo Persson,
>>
>>
>> 1.
>>
>>> That's a remnant from the C language. In C, one library header is
>>> not allowed to include any other, so some things like size_t and
>>> NULL are defined several times.
>>
>> I am not quite sure what do you mean library header? .h file or?
>
> Yes, standard .h files provided with the C compiler.
>
>
>> Could you show me a sample which means "one library header is not
>> allowed to include any other" please?
>>
>> 2.
>>
>> It is fine if there is multiple definitions because of the
>> limitation of C itself as you mentioned, but how to find which
>> definition is the one I am currently using?
>
> They are required to be identical, so you have to worry. In C

or you rather *don't* have to worry. :-)

> "stddef.h" is a good choice to standard typedefs, like size_t or
> NULL. In C++ you could use <cstddef> instead.
>
> If you use Visual Studio, just type size_t and press F1. The help
> page will tell you.
>
>
> Bo Persson




Re: size_t by Doug

Doug
Sun Oct 12 12:53:07 CDT 2008

On Sat, 11 Oct 2008 02:11:01 -0700, George
<George@discussions.microsoft.com> wrote:

>Thanks Doug,
>
>
>1. Do you think it is an IDE bug to prevent mouse to show the correct
>definition and also go to the wrong definition of 32-bit when developing
>64-bit application?

Yeah, I think it's a bug. A good hint was contained in what I originally
told you, namely, "If you want to report the bug..."

>>You're not going to find some IDE setting called "Display correct typedefs
>>in tooltips." If you want to report the bug, you can do so here:

>>http://connect.microsoft.com/feedback/default.aspx?SiteID=210

>2. I have tried without any header files, size_t x will compile. It proves
>size_t is a built-in type?

Again, the answer to your question may be found in what I originally told
you, namely:

>>Try to compile this fragment:
>>
>>size_t x;
>>
>>Last time I checked, it will compile, because VC makes size_t an intrinsic
>>type. This is a (minor) deviation from the standard, which requires size_t
>>to be a typedef defined in various header files.
>
>But I searched MSDN never mentions this

MSDN doesn't mention a lot of things.

>and never describes size_t is for 32-bit for x86 and 64-bit for x64.

But I'm pretty sure it describes size_t WRT x86 and x64. If it doesn't,
well, you can report the documentation bug using the link I gave you in my
first message.

--
Doug Harrison
Visual C++ MVP

Re: size_t by Tim

Tim
Sun Oct 12 23:19:41 CDT 2008

"Bo Persson" <bop@gmb.dk> wrote:
>
>That's a remnant from the C language. In C, one library header is not
>allowed to include any other,

What? You are one of the people whose posts I hesitate to challenge, but I
don't understand where that sentence came from. To my knowledge, that
restriction has NEVER been part of the C language, and I have never seen
that sentence in writing before. Are you suggesting this was a policy goal
in the ISO standard?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: size_t by Tim

Tim
Sun Oct 12 23:22:31 CDT 2008

George <George@discussions.microsoft.com> wrote:
>
>How do you prove size_t is using definitions in crtdefs.h? I have tried
>without any header files included, size_t x could compile. Any comments?

I don't need to prove it. Doug and Bo gave you an excellent analysis of
why this happens. However, IF the crtdefs.h definition was different from
what the compiler had built-in, there would be a compile-time error.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: size_t by Bo

Bo
Mon Oct 13 12:33:04 CDT 2008

Tim Roberts wrote:
> "Bo Persson" <bop@gmb.dk> wrote:
>>
>> That's a remnant from the C language. In C, one library header is
>> not allowed to include any other,
>
> What? You are one of the people whose posts I hesitate to
> challenge, but I don't understand where that sentence came from.
> To my knowledge, that restriction has NEVER been part of the C
> language, and I have never seen that sentence in writing before.
> Are you suggesting this was a policy goal in the ISO standard?

From what I understand, this follows from the requirements of "7.1.3
Reserved identifiers" of the C standard (C99).

One of the bullets says:

"Each identifier with file scope listed in any of the following
subclauses (including the future library directions) is reserved for
use as a macro name and as an identifier with file scope in the same
name space if any of its associated headers is included."

So if you don't include a header, its names are not reserved. This
would break if standard headers included each other.



Bo Persson



Re: size_t by George

George
Tue Oct 14 08:25:01 CDT 2008

Thanks Bo Persson,


1.

> >> That's a remnant from the C language. In C, one library header is
> >> not allowed to include any other, so some things like size_t and
> >> NULL are defined several times.
> >
> > I am not quite sure what do you mean library header? .h fil