I am trying to understand what the following line of the worst-ever-seen C code (from uboot project) mean:
rc = ((ulong (*)(bd_t *, int, char *[]))addr) (bd, --argc, &argv[1]);
What is it? A function call? Can it be more readable?
Thanks in advance for your help!
The symbol "⊆" means "is a subset of". The symbol "⊂" means "is a proper subset of". Example. Since all of the members of set A are members of set D, A is a subset of D. Symbolically this is represented as A ⊆ D.
The C with bar (majuscule: Ꞓ, minuscule: ꞓ), also known as barred C, is a modified letter of the Latin alphabet, formed from C with the addition of a bar.
capsule. c. cum. with (usually written with a bar.
Yes, it's a function call.
It casts the value in addr
to a function pointer which accepts (bd_t *, int, char *[])
as arguments and returns a ulong
, and calls the function. It could be sugared into:
typedef ulong (*bd_function)(bd_t *bd, int argc, char *argv[]);
bd_function bdfunc = (bd_function) addr;
rc = bdfunc(bd, --argc, &argv[1]);
This might be overkill, to introduce a typedef
if this only happens once, but I feel it helps a lot to be able to look at the function pointer's type separately.
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