Yahoo India Web Search

Search results

  1. Dictionary
    volatile
    /ˈvɒlətʌɪl/

    adjective

    noun

    • 1. a volatile substance.

    More definitions, origin and scrabble points

  2. Oct 29, 2008 · 258. volatile in C actually came into existence for the purpose of not caching the values of the variable automatically. It will tell the compiler not to cache the value of this variable. So it will generate code to take the value of the given volatile variable from the main memory every time it encounters it.

  3. Jan 13, 2016 · Analyzing (*((volatile uint32_t *)0x40000000)) 0x40000000 is the address of register in your micro memory map. the register is 32 bits wide, that means must be uint32_t *. volatile is added to tell compile to avoid to optimize that variable because of could change, for example, in an interrupt routine. last: the * dereference the pointer: make ...

  4. Jun 19, 2023 · The volatile keyword in C++ was inherited it from C, where it was intended as a general catch-all to indicate places where a compiler should allow for the possibility that reading or writing an object might have side-effects it doesn't know about. Because the kinds of side-effects that could be induced would vary among different platforms, the Standard leaves the question of what allowances to make up to compiler writers' judgments as to how they should best serve their customers.

  5. In your example, the two are the same. But the issues revolve around pointers. First off, volatile uint8_t *foo; tells the compiler the memory being pointed to is volatile. If you want to mark the pointer itself as volatile, you would need to do uint8_t * volatile foo; And that is where you get to the main differences between marking the struct ...

  6. Sep 13, 2013 · The volatile keyword grossly means that the compiler should really access and write the qualified data at each occurrence. As a stupid example, consider the loop. #define REG(x) (*((volatile unsigned int *)(x))) for (REG(0x1234)=0; REG(0x1234)<10; REG(0x1234)++) dosomethingwith(REG(0x1234)*2); If you did not put the volatile keyword, an ...

  7. Feb 28, 2018 · Yes, consider the below. Compiler could reason (char *) 0x2000000 was read once, no need to read again for volatile char var2 = * (char *) 0x2000000;. Just use the value that was read before and saved away in some internal memory/register. Targets var1/var2, being volatile, do not affect the right-hand-side of the assignment.

  8. The volatile keyword is used in C to prevent the compiler performing certain optimizations, amongst other subtle changes, on a variable. For example; volatile int my_int = 0; creates an integer. In some situations it may prevent the following optimization: while(my_int == 0); // Loop until my_int != 0. Optimize to:

  9. Jun 11, 2009 · Just a warning on the C/C++ volatile keyword. Unless you know what you are doing you should never use it. C/C++ volatile != java/C# volatile volatile does not help in threaded code unless you really know what you are doing, you need to use C++0x atomic template (or something similar).

  10. volatile will tell the compiler not to optimise code related the variable, usually when we know it can be changed from "outside", e.g. by another thread. const will tell the compiler that it is forbidden for the program to modify the variable's value. const volatile is a very special thing you'll probably see used exactly 0 times in your life (tm).

  11. Jan 8, 2020 · It is usually used to access hardware registers mapped into the address space, or some particular memory addresses. Hardware registers should be defined as volatile as registers can change without any program activity (as they are changed by the hardware). #define GPIOREGA ((volatile uint32_t *) 0x6FC0) then you can assign or read this memory ...