Basic and Advance C Question:
Download Job Interview Questions and Answers PDF
I have seen function declarations that look like this
Answer:
I've seen function declarations that look like this:
extern int func __((int, int));
What are those extra parentheses and underscores for?
They're part of a trick which allows the prototype part of the function declaration to be turned off for a pre-ANSI compiler. Somewhere else is a conditional definition of the __ macro like this:
#ifdef __STDC__
#define __(proto) proto
#else
#define __(proto) ()
#endif
The extra parentheses in the invocation
extern int func __((int, int));
are required so that the entire prototype list (perhaps containing many commas) is treated as the single argument expected by the macro.
extern int func __((int, int));
What are those extra parentheses and underscores for?
They're part of a trick which allows the prototype part of the function declaration to be turned off for a pre-ANSI compiler. Somewhere else is a conditional definition of the __ macro like this:
#ifdef __STDC__
#define __(proto) proto
#else
#define __(proto) ()
#endif
The extra parentheses in the invocation
extern int func __((int, int));
are required so that the entire prototype list (perhaps containing many commas) is treated as the single argument expected by the macro.
Download C Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
I came across some code that puts a (void) cast before each call to printf. Why? | Why do some people write if(0 == x) instead of if(x == 0)? |