4

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 Answers1

7

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 ().

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142