Multiple assignment in one line

后端 未结 10 997
天涯浪人
天涯浪人 2020-11-30 04:22

I just come across the statement in embedded c (dsPIC33)

sample1 = sample2 = 0;

Would this mean

sample1 = 0;

sample2 = 0;
         


        
10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 04:45

    You can yourself decide that this way of coding is good or bad.

    1. Simply see the assembly code for the following lines in your IDE.

    2. Then change the code to two separate assignments, and see the differences.

    In addition to this, you can also try turning off/on optimizations (both Size & Speed Optimizations) in your compiler to see how that affects the assembly code.

提交回复
热议问题