void
usage (cpp)
register const char *const *cpp;
{
(void) fprintf (stderr, *cpp++, program_name, cvs_cmd_name);
for (; *cpp; cpp++)
(void) fprintf (stderr, *cpp);
error_exit ();
}
I don't get why register variable is not inside the curly brackets and what is this (void) in front of fprintf? Also register const char *const *cpp, i've never seen anything like this before
const char* const says that the pointer can point to a constant char and value of int pointed by this pointer cannot be changed. And we cannot change the value of pointer as well it is now constant and it cannot point to another constant char.
const char *ptr : This is a pointer to a constant character. You cannot change the value pointed by ptr, but you can change the pointer itself. “const char *” is a (non-const) pointer to a const char.
In general, you can pass a char * into something that expects a const char * without an explicit cast because that's a safe thing to do (give something modifiable to something that doesn't intend to modify it), but you can't pass a const char * into something expecting a char * (without an explicit cast) because that's ...
const char* is a pointer to a constant char, meaning the char in question can't be modified. char* const is a constant pointer to a char, meaning the char can be modified, but the pointer can not (e.g. you can't make it point somewhere else).
The reason you've "never seen this before" is because this is using the syntax of the original, historical, K&R C version. That must be some real, old C code you're looking at. I just looked up, and ANSI C (C90) came out in 1990, so this code must be at least 30 years, or so, old.
I suppose this is something that needs to be known if one needs to deal with historic C code, but otherwise you can simply forget it.
The (void)
cast means the same thing it means today.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With