Quantcast
Channel: Active questions tagged questions - Meta Stack Overflow
Viewing all articles
Browse latest Browse all 603

Would asking about ways to avoid mentioning a function pointer's arguments inside the definition of a function that takes it as argument be on topic?

$
0
0

I'm writing this C code that involves passing around a lot of function pointers, and sometimes writing all the arguments that a function pointer takes when defining a function that takes it as a variable can significantly increase the length of the function definition and thus decrease its readability. For instance, say I have this function foo that takes three ints and a function pointer to perform a certain operation. The typical way to declare a function like foo is something along the lines of:

int foo(int a, int b, int c, int (*operation) (int, int, int));

I was wondering if it would be on topic for SO to ask if there was a possible way to avoid the redundancy of having to re-mention the variable types another time in the type of the function pointer.

An answer to this question suggests that it is possible to only use empty parentheses () , which translates in the above example to:

int foo(int a, int b, int c, int (*operation) ());

However, a comment to the same post states that this kind of syntax is going to be removed in C23:

As a side note, this is obsolescent C since year 1989. Emptyparenthesis () no prototype style should not be used. And it willfinally get removed in upcoming C23


Viewing all articles
Browse latest Browse all 603

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>