Why does const create a different signature when its applied to a struct pointer as opposed to a struct?
E.g.
typedef struct test_s {
int foo;
} test;
void foo(test *ptr){
return;
}
// This is ok
void foo(const test *ptr){
return;
}
void foo(test t){
return;
}
//This is an error
void foo(const test t){
return;
}
(tested on gcc version 4.9.2)
To be more specific, why is it that the bottom one is an error when the pair with the pointers is not an error. The referenced duplicate question (Functions with const arguments and Overloading) would also seem to argue that the case with the pointers should be duplicates.