size_t

Hi

Where is size_t usually defined?  I am using C++, and I cannot find a
typedef something size_t;

I do find something like this in a file
 #define _SIZT      size_t

But I do not know what  _SIZT is.
LuckyLucksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
There are prior question such as yours. Presumably you are programming in a windows env where according to those _SIZT IS A vendor macro defined to size_t.

Can not post the link here, but searching for _SIZT c++ will list a similar question to your from 2006.
0
jkrCommented:
'size_t' isn'd '#define'd anywhere (in terms of a preprocessor macro expansion), it is ''typedef'd, i.e. defined as a type by code that your compiler processes - while quite 'similar' to a '#define', this is not even close to be the same thing. It introduces a - well, not so new - type that basically resembles an unsigned integer of the platform you are on (32 or 64 bits).
0
n2fcCommented:
size_t is the unsigned integer type of the result of the sizeof operator (ISO C99 Section 7.17.)

The actual type of size_t is platform-dependent; a common mistake is to assume size_t is the same as unsigned int, which can lead to programming errors, particularly as 64-bit architectures become more prevalent.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

evilrixSenior Software Engineer (Avast)Commented:
The actual definition of size_t can normally be found in cstdlib; however, it can also be defined in any of the following :

<cstddef>
<cstdio>
<cstring>
<ctime>
<cstdlib>
0
sarabandeCommented:
#define _SIZT      size_t
#define defines macros from left to right. so the statement you found "makes" _SIZT to be a synonym for size_t and not the other way round.

_SIZT is a macro defined in <xmemory> what is a header file for standard lib STL of the visual c++ compiler. i found it in vs2008 (vc9) but not in vs2012 (vc11) what it is a strong evident that it was used for compability reasons to older versions of visual c++ compiler.

the size_t in current versions of visual c++ compiler is indeed a typedef (as stated by jkr) in the VC include file vadefs.h

typedef _W64 unsigned int   size_t;

Open in new window


for a WIN32 project where _W64 is a macro that is defined as

#define _W64 __w64

where __w64 is a compiler macro that is used for 32-bit projects (x86) only  according the following MS statement:

Any typedef that has __w64 on it must be 32 bits on x86 and 64 bits on ARM and x64.
(it probably is some kind of MS running gag to using the sequence '64' only for 32-bit purposes),

Sara
0
evilrixSenior Software Engineer (Avast)Commented:
>> it probably is some kind of MS running gag to using the sequence '64' only for 32-bit purpose
In much the same way as they insist on using WIN32 even for 64 bit programs :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.