c - What's the use of defining ARGS in a different header file? -


so i've been going through code, , there's things can't understand. have 2 header files. 1 called 'args.h' , in there these statements, amongst others:

#if (defined(__cplusplus) || defined(__stdc__) || defined(c_plusplus)) #define new_style 1 #define void    void #define args(parenthesized_list) parenthesized_list #else #define new_style 0 #define void #define args(parenthesized_list) () #define const #endif  #if !defined(exit_success) #define exit_success    0 #define exit_failure    1 #endif 

in other header file, function prototypes declared this:

#if defined(__cplusplus) extern "c" { #endif  extern void     yyerror args((const char *s_)); extern int      yylex args((void)); extern int      yyparse args((void)); extern int      yywrap args((void));  #if defined(__cplusplus) } #endif 

and bunch of other stuff.

so questions are:

1> #define const do?

2> why arg declared in other header file? couldn't declare functions normal extern void a(const char *s__)? or preference of style?

thanks.

this allow code compile pre-standard c compiler. turns function prototype function declaration, , removes const completely.

if need use compiler ancient doesn't understand prototypes or const, have little choice use this. otherwise, you're best off eliminating these horrible kludges.

20 years ago, code common , necessary. seems harder excuse today, suppose there may still few platforms reasonably modern compiler isn't available.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -