using sizeof () to find function type length in ANSI C -
this question has answer here:
- why size of function in c 1 byte? 4 answers
when need find function type length, used sizeof () it.
the expected result 4 bytes , 8 bytes, now, result 1 byte through gcc.
why output 1 byte, not 4 bytes , 8 bytes?
#include <stdio.h> int foo (); double bar (); int main (void) { printf ("int foo () %lu\n", sizeof (foo)); printf ("double bar () %lu\n", sizeof (bar)); } double bar (void) { return 1.1; } int foo (void) { return 0; }
although standard says "the sizeof
operator shall not applied expression has function type" (§6.5.3.4/1), in gnu c, result of doing defined:
"
sizeof
allowed on void , on function types, , returns 1"
~ gcc, 6.23 arithmetic on void- , function-pointers
also have at: why size of function in c 1 byte?
Comments
Post a Comment