Never seen this syntax before. Help?

This is a discussion on Never seen this syntax before. Help? within the C Programming forums, part of the General Programming Boards category; I'm taking a look at all the good stuff GNU has made and I ran into something I have never ...

PARAMS is defined either in the file or in a header, so you should be able to find it; but what it does is allow you to switch between old-style K&R function declarations and honest-to-goodness prototypes. So in K&R mode that last function would be

Let me show what I do understand so far so maybe someone can fill in the gaps.

void (*print_object_filename) PARAMS ((char *filename));
for example

void indicates I'm declaring a pointer which I'm assuming is going to be called (*print_object_filename).

PARAMS gets replaced with ARGS before compilation so we really have
void (*print_object_filename) ARGS ((char *filename));

and then what follows is the parameters of the function.

It's still a little hazy though.
Is this a declaration or a prototype?
I'm not quite following your reasoning tabstop. In your second code snippet what happens to the PARAM? It looks like you just took it out of the code.

As to the other, your search and replace skills need work. Look at the definition:

Code:

#define PARAMS(ARGS) ARGS

This means that "PARAMS(ARGS)" gets replaced by "ARGS" where, since this is a pseudofunction, ARGS is whatever you actually type in inside the parentheses. Since you typed in "(char *filename)" inside the parentheses, that's what ARGS is -- "(char *filename)". So that is what the macro expands to.

In fact, if you look at the definition of the macro, PARAMS gets taken out of the code.

They're function pointers, which, as the name suggests, are pointers that point to functions.

You probably have something like:

Code:

#if __STDC__
#define PARAMS(p) p
#else
#define PARAMS(p) ()
#endif

So if you're using standard C (that is, prototypes are available), you get:

Code:

void (*print_object_filename)(char *filename);

and if you're not, you get:

Code:

void (*print_object_filename)();

It's a bit difficult at first to unwind the declarations, but the prototyped one is this: print_object_filename is a pointer to a function that takes a char* and returns nothing. So you can assign to it a function (pointer) that matches the prototype: