#define SL_PORT_REGISTER(port, sl_register) *(uint32_t *)(SL_PORTS + (port*SL_PORT) + sl_register)
The port*SL_PORT multiplication would not become misinterpreted?
I would hope so, because port somethingsomething doesn't make any sense in C so the * has to be multiplication.
I have never heard of compilers confusing the two as long as the code is correct and doesn't try to multiply without anything on the left side of * or things like that.
This is the kind of stuff C does to make you lose your mind.
Standard says*: The operand of the unary * operator shall have pointer type.
Which I think means that, for rvalues, as long as whatever you put after the * isn't a pointer type, it will be multiplication.
*6.5.3.2 Address and indirection operators
Nope, here is an rvalue interpreted as a dereference of a float variable.
$ cat asterisk.c
int main() {
float p=3.14;
return *p;
}
$ clang asterisk.c -o /dev/null
asterisk.c:3:9: error: indirection requires pointer operand ('float' invalid)
return *p;
^~
1 error generated.
GCC would do the same but the error message doesn't spell it out as explicitly so I used clang for this example.
This distinction is made syntactically, based on whether the code matches pattern A*B or only *B.