3 ms·
Would you give C examples of this? I am having trouble imagining how a cast would look like a function call to the compiler.
by ryao 3y ago
Would you give C examples of this? I am having trouble imagining how a cast would look like a function call to the compiler.
- trealira 3y agoAlthough I'm not who you asked, I can think of a slightly contrived example. If a is a variable name, then this is using b as the first argument to call the function a (which is surrounded by unnecessary parentheses). If it's a type name, it's casting b to the type a. result = (a)(b);
- WalterBright 3y agoIt's not contrived enough - it happens in real C code.
- trealira 3y agoMy example is slightly contrived because the parentheses around b are unnecessary to cast it, but it becomes more realistic if it's a more complex expression like this: (foo)(a + b) Or this: // Comma expression or function call arguments? (bar)(first = side_effect++, second)
- WalterBright 3y agoYeah, (a)(b,c) is that a comma-expression or an argument list?