what does register const char *const *name; mean and why is this variable outside of the function?

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.


The register keyword is a hint to the compiler that you'd like that value to be kept in a dedicated register on the processor. This can speed up reads and writes. With modern compilers, however, this sort of optimization is not only unnecessary but often counterproductive.

The reason it is between the function declaration and the block is that in old c (pre C90) you wouldn't declare parameter type next to the parameter but between the declaration of the function and the block.

For example:

int main(argc, argv)
char ** argv;
{
 ...
}

Notice I didn't do anything for argc because if you don't explicitly define a type it defaults to int.

You'll see this more often than you'd think. I ran into this a bunch when I did work on FFMPEG.

The (void) cast thing prevents unused parameter warnings/errors. I've run into this when working on PortAudio with a low-level callback function.

Tags:

C