Given the following C source code:
const int foo(void)
{
return 42;
}
gcccompiles without errors, but with -Wextraor -Wignored-qualifiersthe following warning appears:
warning: type qualifiers ignored on function return type
I understand that in C ++ there is a good reason to distinguish between functions constand not functions const, for example. in the context of operator overloading.
In simple C, however, I do not understand why it gccdoes not emit an error, or more briefly, why the standard allows functions const.
Why are type qualifiers allowed to return function types?
source
share