According to the C11 standard, the previous code could generate an undefined behavior, and would also generate a warning if compiled using clang:
make
clang++ -Wall -fPIC -c RF24Mesh.cpp
RF24Mesh.cpp:256:6: warning: unsequenced modification and access to 'reqCounter' [-Wunsequenced]
(++reqCounter) = reqCounter%4;
^ ~~~~~~~~~~
RF24Mesh.cpp:257:6: warning: unsequenced modification and access to 'totalReqs' [-Wunsequenced]
(++totalReqs) = totalReqs%10;
^ ~~~~~~~~~
2 warnings generated.
Splitting the increment and assign into multiple lines solves that, whilst improving readability and eliminating the warnings thrown by clang (which means that the code now compiles with no warnings at all under it!).
According to the C11 standard, the previous code could generate an undefined behavior, and would also generate a warning if compiled using clang:
Splitting the increment and assign into multiple lines solves that, whilst improving readability and eliminating the warnings thrown by clang (which means that the code now compiles with no warnings at all under it!).