volatile variables as argument to function

前端 未结 5 1538
天命终不由人
天命终不由人 2020-12-09 12:58

Having this code:

typedef volatile int COUNT;       

COUNT functionOne( COUNT *number );

int  functionTwo( int *number );

I can\'t get ri

5条回答
  •  执笔经年
    2020-12-09 13:36

    It's possible that those who wrote it wanted to be sure that all the operations are atomic, and declared all int variables as volatile (is it a MT application with poor syncronization?), so all the ints from the code are declared as volatile "for consistency".

    Or maybe by declaring the function type as volatile they expect to stop the optimizations of the repeated calls for pure functions? An increment of a static variable inside the function would solve it. However, try to guess their original intention, because this just does not make any sense.

提交回复
热议问题