Should I always include stddef.h if I use sizeof and size_t

yCalleecharan picture yCalleecharan · Apr 9, 2010 · Viewed 44.8k times · Source

if I'm using the sizeof operator and making use of size_t in my code, do I have necessarily have to include stddef.h? I haven't included stddef.h, and my code compiles without warning with both MVS2008 and with Borland C++ BuilderX.

Thanks a lot...

Answer

DevSolar picture DevSolar · Apr 9, 2010

sizeof(), while looking like a function call, is actually an operator and part of the language core. No include needed.

size_t is defined in various headers: stddef.h, string.h, stdlib.h, and stdio.h. Including any one of them is enough to use size_t in your code.