当前位置: 技术问答>linux和unix
”整型变量j说明为volatile,这样就阻止了优化程序除去循环语句“ 这么理解这句话,为什么会除去循环语句?
来源: 互联网 发布时间:2015-10-10
本文导语: #include #include "ourhdr.h" unsigned int sleep2(unsigned int); static void sig_int(int); int main(void) { unsigned int unslept; if (signal(SIGINT, sig_int) == SIG_ERR) err_sys("signal(SIGINT) error"); unslept = sleep2(5); printf("sleep2 returned: %un", unsle...
#include
#include "ourhdr.h"
unsigned int sleep2(unsigned int);
static void sig_int(int);
int
main(void)
{
unsigned int unslept;
if (signal(SIGINT, sig_int) == SIG_ERR)
err_sys("signal(SIGINT) error");
unslept = sleep2(5);
printf("sleep2 returned: %un", unslept);
exit(0);
}
static void
sig_int(int signo)
{
int i;
volatile int j;
printf("nsig_int startingn");
for (i = 0; i
#include "ourhdr.h"
unsigned int sleep2(unsigned int);
static void sig_int(int);
int
main(void)
{
unsigned int unslept;
if (signal(SIGINT, sig_int) == SIG_ERR)
err_sys("signal(SIGINT) error");
unslept = sleep2(5);
printf("sleep2 returned: %un", unslept);
exit(0);
}
static void
sig_int(int signo)
{
int i;
volatile int j;
printf("nsig_int startingn");
for (i = 0; i