What is the role of this macro in function declaration?

I downloaded some library and declares functions as follows:

#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 __ANSI_PROTOhere? Why is it easy to declare just like

int httpdAddVariable (httpd*,char*, char*);
+4
source share
1 answer

Pre-ANSI C does not support this:

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

It only supports this:

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

So what does the macro do. It inserts argument types into the declaration if it detects prototype support; otherwise it just inserts ().

+7
source

Source: https://habr.com/ru/post/1665640/


All Articles