8.5. Sequence pointsAssociated with, but distinct from, the problems of real-time programming are sequence points. These are the Standard's attempt to define when certain sorts of optimization may and may not be permitted to be in effect. For example, look at this program:
#include <stdio.h>
#include <stdlib.h>
int i_var;
void func(void);
main(){
while(i_var != 10000){
func();
i_var++;
}
exit(EXIT_SUCCESS);
}
void
func(void){
printf("in func, i_var is %d\n", i_var);
}Example 8.6The compiler might want to optimize the loop so that a[i] = i++; because there is no sequence point specified for the assignment,
increment or index operators, you don't know when the effect of the
increment on The sequence points laid down in the Standard are the following:
|
The C BookThis book is published as a matter of historical interest. Please read the copyright and disclaimer information. GBdirect Ltd provides up-to-date training and consultancy in C, Embedded C, C++ and a wide range of other subjects based on open standards if you happen to be interested. |
|
West Yorkshire Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday South East Regional Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday Please note: |