Re:C/C++ Pointer Declaration Syntax – It makes sense
by gsg on Tuesday February 21, 2012 @09:58AM
(#3616639)
I've always found it unsurprising that people find typedefs
confusing. They're a storage specifier, which allows for some questionable constructs:
int typedef x;
typedef what;
struct { int x; } typedef *x, y;
enum { x } typedef;
Storage specifiers are pretty weird. This nonsense is allowed at function or parameter list scope, but not file scope: void f() { enum { x } register; }
void f(enum { x } register);
I've never understood why Ritchie designed C's declaration syntax to have so many dumb edge cases.
At the beginning it might seem that typedefs alias some A to some B.
Which could lead to confusing which side is the one you are defining and which is the produced.But typedefs basically work as variable decl but they declare a type, so:
this will declare myfunc as a type which is a pointer to a function expecting two integers and returning void.