C standard forbids it – when compiled with gcc -pedantic
, it produces invalid application of ‘sizeof’ to a function type
warning.
However gcc
compiles it and returns 1
for sizeof(main)
, and it is not a size of function pointer.
It seems to be compiler-dependent.
More Related Contents:
- Why isn’t the size of an array parameter the same as within main?
- C sizeof a passed array [duplicate]
- Why does a C-Array have a wrong sizeof() value when it’s passed to a function? [duplicate]
- Why is the size of a function in C always 1 byte?
- How do I modify a pointer that has been passed into a function in C?
- Default argument promotions in C function calls
- C Programming: malloc() inside another function
- Difference between passing array and array pointer into function in C
- Override a function call in C
- sizeof() operator in if-statement
- What does the ‘array name’ mean in case of array of char pointers?
- Why is sizeof considered an operator?
- Why is this happening with the sizeof operator when comparing with a negative number? [duplicate]
- Returning a pointer to an automatic variable
- sizeof with a type or variable
- size of character array and size of character pointer
- C – allocating a matrix in a function
- Function Returning Itself
- Strange warning in a C function const multidimensional-array argument
- in c: func(void) vs. func() [duplicate]
- What is the reason function names are prefixed with an underscore by the compiler?
- How to use the rand function to make numbers in a specific range?
- What’s sizeof(size_t) on 32-bit vs the various 64-bit data models?
- Avoiding the main (entry point) in a C program
- Reliably determine the number of elements in an array
- C -> sizeof string is always 8
- Size of pid_t, uid_t, gid_t on Linux
- Pass by reference in C
- Need for prefixing a function with (void)
- How sqrt() of GCC works after compiled? Which method of root is used? Newton-Raphson?