When writing code in C, I often include const
in function parameter declarations in the function's definition, but not its declaration:
int func(int arg);
...
int func(int const arg)
{
return arg + 1;
}
This has always compiled for me without issue using GCC and Clang, but Microchip's C18 compiler is claiming a type mismatch.
What does the standard have to say about this? Have I been relying on a non-standard extension?
Edit: I am not asking about the benefits of this and I am not asking about C++ as in the supposed duplicate question (Use of 'const' for function parameters). I am asking about the C standard: Is this legal ANSI C, C99, or C11?