[Info-vax] yet another sys$qiow question

Johnny Billquist bqt at softjar.se
Thu Aug 20 09:17:36 EDT 2015


On 2015-08-19 20:43, JF Mezei wrote:
> On 15-08-19 09:12, Johnny Billquist wrote:
>
>> So, you need to tell the C compiler that iosb can indeed be modified
>> outside of the flow of the program, so that the compilar cannot make
>> optimizations with regards to the read of the iosb variable. And that is
>> what volatile do.
>
>
> Iteresting use of vocabulary. To me, "volatile" would imply that the
> variable can be optimized away or be temporarily allocated (aka: not
> garanteed to survive after end of subroutine).
>
> But based on reading here, "volatile" means the exact opposite, that it
> is a variable that must not be optimized away, and much remain allocated.
>
> So, if I have a variable or IOSB structure which is declared outside of
> a subroutine in C, what sttribute before "struct" do I put to enable
> that "volatile" thing ?

You are talking about the scope of a variable, which is something 
totally unrelated.

A temporary variable, allocated inside a routine, can be volatile, or 
not. That is a separate issue from where it is allocated, or where the 
memory is freed. You are confusing two different and unrelated concepts.

volatila have nothing to do with where or when a variable gets created 
or allocated. Neither does it have anything to do with where and when 
the memory gets freed again.
volatile is about what assumptions the compiler can make about the 
*contents* of the variable.

	Johnny




More information about the Info-vax mailing list