473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is size_t a keyword?or a macro?

if size_t is a macro, where is the defination? i look it up in the stddef.h,
but i find nothing about size_t.

this is the content of stddef.h of my system,
#ifndef _LINUX_STDDEF_H
#define _LINUX_STDDEF_H

#undef NULL
#if defined(__cplus plus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif

#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

#endif

i regard the size_t as unsigned int or unsigned long, and i am not very
confidence.

Please help me!

yours Guocongbin
2004.6.17
Jul 22 '05 #1
2 2338
Guo Congbin wrote:
if size_t is a macro, where is the defination?
size_t is a typedef, not a keyword or a macro. The C standard says it's
declared in several header files, including <stddef.h>. In C++, the
<stddef.h> header is deprecated, and you should use <cstddef> instead. In
<cstddef>, size_t is in the std namespace (std::size_t).
i look it up in the stddef.h, but i find nothing about size_t.

this is the content of stddef.h of my system, [snip]

The header file you quoted doesn't seem to conform to the requirements of
the C standard. Perhaps there's another stddef.h file somewhere? If not,
try looking in cstddef, stdio.h, stdlib.h, string.h, time.h, or wchar.h.
i regard the size_t as unsigned int or unsigned long, and i am not very
confidence.


The C++ standard defers to the C standard on this issue. The C standard
says only that size_t is the type returned by the sizeof operator, and that
it is some sort of unsigned integral type. The specific type varies from
implementation to implementation. It might even be a platform-specific type
(I think the Microsoft <stddef.h> typedefs it to some type called unsigned
__int64). If you really need to know what size_t is, you'll have to find it
in your header files, or possibly in the documentation that comes with your
library.

--
Russell Hanneken
eu*******@cbobk .pbz
Use ROT13 to decode my email address.
Jul 22 '05 #2
Guo Congbin wrote:

if size_t is a macro, where is the defination? i look it up in the stddef.h,
but i find nothing about size_t.
It's usually a typedef. If it isn't directly defined in <cstddef> then
it's probably in a header included by it.
i regard the size_t as unsigned int or unsigned long, and i am not very
confidence.


Why do you care? The standard says that size_t is an unsigned integral
type large enough to hold the size of the largest required object in the
implementation (SIZE_MAX). That's all you need to know.

Brian Rodenborn
Jul 22 '05 #3

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

Similar topics

4
3031
by: Guo Congbin | last post by:
·¢¼þÈË: "Guo Congbin" <guocongbin@sei.buaa.edu.cn> Ö÷Ìâ: is size_t a keyword?or a macro? ÈÕÆÚ: 2004Äê6ÔÂ17ÈÕ 23:04 if size_t is a macro, where is the defination? i look it up in the stddef.h, but i find nothing about size_t. this is the content of stddef.h of my system, #ifndef _LINUX_STDDEF_H #define _LINUX_STDDEF_H
11
19474
by: javadesigner | last post by:
Hi: I am a bit new to C programming and am trying to write a wrapper around malloc. Since malloc takes size_t as it's parameter, I want to be able to see if my function recieved an argument less than or equal to the max size_t type. So:
16
6114
by: Xenos | last post by:
Is there a standard way to determine the max. value of size_t as a compile-time constant? Will: #define SIZE_T_MAX ((size_t) -1) work in all cases, or just on 2s comp. machines? DrX
7
2860
by: Pedro Graca | last post by:
#include <stdio.h> #ifdef C99 #define FMT_STRING "The value is %zu.\n" #define CAST_SIZE_T #else #define FMT_STRING "The value is %lu.\n" #define CAST_SIZE_T (unsigned long) #endif
13
1550
by: sam_cit | last post by:
Hi Everyone, I was looking at the function prototype of malloc() function in stdlib.h and i found that to be, void *malloc(size_t size); so what is size_t is it a pre-defined typedef to int? Thanks in advance.
22
27025
by: subramanian100in | last post by:
Consider the following program #include <limits.h> #include <stddef.h> int main(void) { size_t size; size_t bytes = sizeof(size_t);
25
11659
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, When converting from size_t to unsigned int, there will be a warning message, warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data I do not know why, since in crtdbg.h, size_t is defined to int, right?
89
5670
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the right thing to use for every var that holds the number of or size in bytes of things. * size_t should only be used when dealing with library functions.
50
11804
by: jacek.dziedzic | last post by:
Hi! On a machine where size_t is 64-bit, unsigned long is 32-bit, how does one construct a size_t literal that says 2^32? Typing in size_t x = 4294967296UL; complains about the value being too large for unsigned long (obviously, it's too large by one).
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.