Newsgroups: comp.lang.c
From: "Alex Vinokur" <ale...@big.foot.com>
Date: Wed, 17 Mar 2004 09:52:56 +0200
Local: Wed, Mar 17 2004 2:52 am
Subject: Re: What is volatile?
"Anil Akkur" <anilak...@yahoo.co.in> wrote in message news:d46b1147.0403162202.74cbd777@posting.google.com... -------------------------------------------------- > Hi All, > Please explain me exact meaning of "volatile" qualifier? Where exactly we use it? > Please explain me with a code snippet. > Thanks in advance. Compiler : GNU gcc version 3.3.1 (cygming special) -------------------------------------------------- ====== C code : BEGIN ====== } ---------------------------- ------ File foo2.cpp ------- } ---------------------------- ====== C code : END ======== ====== Compilation (No optimization): BEGIN ======== $ gcc -save-temps foo1.c $ gcc -save-temps foo2.c $ ls foo*.s $ diff foo1.s foo2.s > .file "foo2.c" ====== Compilation (No optimization): END ========== ====== Compilation (Optimization O1): BEGIN ======== $ gcc -O1 -save-temps foo1.c $ gcc -O1 -save-temps foo2.c $ ls foo*.s $ diff foo1.s foo2.s > .file "foo2.c" 15,16c15,20 < movl 4(%eax), %eax < movsbl 1(%eax),%eax --- > movl 4(%eax), %edx ====== Compilation (Optimization O1): END ========== > movsbl (%edx),%eax > movl %eax, -4(%ebp) > movsbl 1(%edx),%eax > movl %eax, -4(%ebp) > movl -4(%ebp), %eax Conclusion. No optimization : Assembler code for foo1.c and foo2.c is identical. -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||