user3778137
user3778137

Reputation:

How do you call functions with __P in the prototype?

I have been going through some header files and see that there are many function prototype like this:

returntype some_name __P(arguments);

If I were to call this function how do I do it? Do I use something like

some_name(arguments);

excluding the __P, or is there some other way to call such functions?

Upvotes: 1

Views: 161

Answers (1)

chqrlie
chqrlie

Reputation: 145297

This kind of prototype uses a macro __P to allow inclusion and compilation on very old systems that do not support C90 prototypes (aka ansi prototypes).

On most systems, the argument to the __P macro expands to the argument list, as illustrated below:

#ifdef __USING_STONE_AGE_COMPILER__
#define __P(args)  ()
#else
#define __P(args)  args

int some_name __P((int argc, char *argv[]));

On obsolete systems, the above declaration expands to int some_name(); whereas it expands to the full prototype otherwise: int some_name(int argc, char *argv[]);

Just ignore the __P macro and use some_name(arguments); syntax to call the function. Also note that the macro name __P is not significant, the author of the package could have used any name for this purpose.

Upvotes: 3

Related Questions