In C and C++ a variable can be marked as volatile, which means the compiler will not optimize it because it may be modified external to the declaring object. Is there an eq
According to The Delphi Language for Mobile Development whitepaper, Delphi's mobile compilers have supported a [volatile] attribute since they were first introduced:
The
volatile
attribute is used to mark fields that are subject to change by different threads, so that code generation does not optimize copying the value in a register or another temporary memory location.You can use the
volatile
attribute to mark the following declarations:
- Variables (global and local)
- Parameters
- Fields of a record or a class.
You cannot use the volatile attribute to mark the following declarations:
- Type
- Procedures, Functions or Methods
- Expressions
type TMyClass = class private [volatile] FMyVariable: TMyType; end;
Starting with Delphi 10.1 Berlin, the desktop compilers now support [volatile]
as well.
Attributes Supported by All Compilers
Now, all Delphi compilers support the following attributes:
- unsafe
- volatile
- weak