Volatile
Hi ppl
Can any body here make this "volatile" more clear in terms of C language with some practical example i.e why we need it? or for what it can be used for ?
thanks
ankit
Send instant messages to your online friends http://uk.messenger.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 6 lines · Ankit Jain
Hi ppl
Can any body here make this "volatile" more clear in terms of C language with some practical example i.e why we need it? or for what it can be used for ?
Volatile provides a hint to the compiler not to act oversmart by performing optimizations on the variable ;-). This is because the the value of the variable may be modified from elsewhere (for e.g. interrupts etc) which the compiler is not aware of. Hence it should not cache it anywhere, and should always generate load instructions to read the "fresh" copy.
Regards,
Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs