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

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(__cplusplus)
#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 2313
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
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,...
11
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...
16
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
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
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...
22
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
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...
89
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...
50
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...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.