What is the role of this macro in function declaration?

190 views Asked by At

I have downloaded some library and it declares the functions the following way:

#if !defined(__ANSI_PROTO)
#if defined(_WIN32) || defined(__STDC__) || defined(__cplusplus)
#  define __ANSI_PROTO(x)       x
#else
#  define __ANSI_PROTO(x)       ()
#endif
#endif

int httpdAddVariable __ANSI_PROTO((httpd*,char*, char*));

What is the role of __ANSI_PROTO here? Why it is preferred to declaring simply as

int httpdAddVariable (httpd*,char*, char*);
1

There are 1 answers

2
Petr Skocik On BEST ANSWER

Pre-ANSI C didn't support this:

int httpdAddVariable (httpd*,char*, char*);

It only supported this:

int httpdAddVariable (); /* = arguments unspecified*/

So that's what the macro does. It pastes the argument types into the declaration if it detects prototype support; otherwise, it just pastes ().