sizeof() Operator

When the GCC extensions setting is on, the sizeof() operator computes the size of function and void types. In both cases, the sizeof() operator evaluates to 1. The ISO/IEC 9899-1990 C Standard ("C90") does not specify the size of the void type and functions. The following listing shows an example.

Listing: Using the sizeof() operator with void and function types

int f(int a)
{

    return a * 10;

}

void g(void)

{

    size_t voidsize = sizeof(void); /* voidsize contains 1 */

    size_t funcsize = sizeof(f); /* funcsize contains 1 */

}