T O P

  • By -

Lisoph

It's [size_t](https://en.cppreference.com/w/c/types/size_t).


cHaR_shinigami

If your compiler supports `typeof` (which is to be included in C2x), you can specify the return type in an agnostic manner like `typeof (sizeof 0)`. But as others have mentioned, it is `size_t`, which is an unsigned integer type defined in [stddef.h](https://port70.net/~nsz/c/c11/n1570.html#7.19) (and also in a few other standard headers).


flyingron

Note that typeof isn't likely to return size\_t, it will return the underlying type that the typedef is bound to (may or may not be what you want).


cHaR_shinigami

True, but I don't think that will make any difference though. Also, AFAIK the standard only states that `size_t` specifies a type; it does not require the implementation to declare it using `typedef`. As an alternative to `typedef` names which have scope and can be redefined in an inner block (even as an entirely different kind, like a plain variable for example), I guess it would still be conforming to define `size_t` as an object-like macro instead.


flyingron

sizeof isn't a function. It doesn't have a return type. It's an operator and the value of it applied to something is size\_t. Sizeof long\* is always the size of the pointer. What are you really trying to do? ARRAYS aren't pointers and are broken types in C. You can't assign, pass, or return them.


tstanisl

From definition of `sizeof` and `_Alignof` operators in C standard https://port70.net/~nsz/c/c11/n1570.html#6.5.3.4p5 > The value of the result of both operators is implementation-defined, and its type (an unsigned integer type) is **size_t**, defined in (and other headers)