title: Circular-buffer used in ISR, declared volatile, gives error. Why ? How to fix this?
body: <p>There is an Arduino library called 'ByteBuffer' (found <a href="http://siggiorn.com/?p=460" rel="nofollow">here</a>), which is a circular buffer implementation. I modified it slightly (calling it 'ByteBufferPro'), by chopping off support for all non-byte data-types, and adding few convenience methods. I intend to use this in my Interrupt-Service-Routine, that is already doing some heavy-lifting. To relieve some bit of workload on the ISR, I intend to let the ISR push bytes of information on the circular-buffer (since capturing/storing them is time-critical), but actual processing of that information is not as time-critical, which I do in the main loop().</p>
  
  <p>Following the logic that any variable that can be updated in ISR should have the 'volatile' qualifier in declaration, I did declare the buffer as volatile, but now I am seeing these compilation errors:-</p>
  
  <pre><code>ByteBufferProExample.cpp: In function 'void setup()':
  ByteBufferProExample:12: error: passing 'volatile ByteBufferPro' as 'this' argument of 'void ByteBufferPro::init(unsigned int)' discards qualifiers
  ByteBufferProExample.cpp: In function 'void loop()':
  ByteBufferProExample:24: error: passing 'volatile ByteBufferPro' as 'this' argument of 'void ByteBufferPro::clear()' discards qualifiers
  </code></pre>
  
  <p>Wondering as to what is the reason, and how I might fix this ? Taking the cribbage being about 'this' pointer, I have a feeling that if I turn the implementation of ByteBuffer from C++ to a C one (OO to procedural), that should be an easy way to fix it, although I really like the OO semantics. Would do so, if there is no other way.</p>