The following compiles:
main()
{
int(asdf);
}
It seems this is some strange kind of declaration. I have tried to find code like this, but was unable to. Could someone explain?
It turns out the line
int(asdf);
is equivalent to
int asdf;
which obviously declares an ordinary local variable named asdf.
But you can put parentheses around various parts of the declarator, whether you need to or not. So it's just the same if you write
int asdf;
or
int (asdf);
or
int ((asdf));
Parentheses are allowed in declarators because, sometimes, they're necessary in order to make a significant distinction. For example,
int *ap[10];
declares an array of 10 pointers, while
int (*pa)[10];
declares a pointer to an array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With