Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the role of this macro in function declaration?

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*);
like image 252
Marin Rantic Avatar asked Mar 10 '23 06:03

Marin Rantic


1 Answers

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

like image 143
PSkocik Avatar answered Mar 21 '23 02:03

PSkocik