Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Normally, whenever a function designator (a function's name) is used in an expression, it decays to a function pointer to that function. typeof is one of those exceptions to the "decay" rules of C...
Answer
#1: Initial revision
Normally, whenever a function designator (a function's name) is used in an expression, it decays to a function pointer to that function. `typeof` is one of those exceptions to the "decay" rules of C (C23 6.3.2.1 §4), so if you give it a function type as operand, the result is a function type and not a function pointer type. So it is now possible to write obscure declarations like: ```c void a (void); typeof(a) b; ``` And that's equivalent to: ```c void a (void); void b (void); ``` So therefore given some function `int foo (FILE*, FILE*)`, then`typeof(foo)*` will yield a function pointer of the type `int (*) (FILE*, FILE*)`. Meaning that `operation` and `op` in your example would indeed be equivalent. I would however not recommend this style since it is obscure and also not backwards-compatible. The clearest style IMO, compatible all the way back to C90 is this: typedef int foo_t (FILE*, FILE*); // typedef a function not a pointer ... foo_t* fp1; // function pointer foo_t* const fp2; // function pointer residing in ROM This makes function pointer syntax 100% in sync with object pointer syntax.