const ready only local copies
- by robUK
Hello
gcc 4.4.4 c89
I am just wondering is it worth passing a const into a function.
i.e.
void do_something(const char *dest, const int size)
The size is a ready-only so I don't want to change it. However, some developers never have this as const has it is a local copy that is being used. The pointer is const as you can change the value in the calling routine.
I always have a const on ready-only local copies, as it confirms to anyone reading my code that it is a ready-only variable. And also, when coding I don't make the mistake of changing it without realizing.
Many thanks for any suggestions,