I tried sizeof(printf)
, sizeof(foobar)
etc. where foobar is a user defined function. It returns 1 without any warning or error. Why 1?
Asked
Active
Viewed 105 times
1
-
what'd be the size of a function? how many bytes the underlying cpu opcodes take? how much memory the function occupies? how long the string representing the function's name is? how much space it mallocs during operation? – Marc B Feb 07 '13 at 14:52
-
3see also, http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Pointer-Arith.html#index-void_002c-size-of-pointer-to-2454 – Hasturkun Feb 07 '13 at 14:54
-
I had expected it to be the size of a function pointer, which 1 most probably isn't. – Christian Rau Feb 07 '13 at 14:55
-
@Hasturkun - Thanks a ton for that gcc manual link. – rootkea Feb 07 '13 at 14:59
1 Answers
8
The size of functions is not well defined in C, so the value is meaningless.

unwind
- 391,730
- 64
- 469
- 606