volatile String Problem

Hi guys,
I'm trying to use String Object functions (eg. length(), setCharAt()) on a String Object var that change on a external interrupt function, so I need to add the variable qualifier volatile to this var, but when I try to use the String object functions over this volatile String Variable, the compiler show the following errors:
error: passing 'volatile String' as 'this' argument of 'void String::setCharAt(unsigned int, char)' discards qualifiers [-fpermissive]
So.. if is not possible to use the String Object Functions on a volatile String, what can I do? or maybe I'm doing something wrong?

Thanks in advance!

"Passing volatile" - are you using the volatile keyword as part of a function parameter?

void myfunction(volatile int a)
{
}

If so, leave it off. If not, perhaps paste your code here and something obvious might pop up.

Hi David, thanks for you response
here is part my code

volatile char wiegandOutput[27];
volatile byte index = 0;

//interrupt Function
void readDATAZERO(){
  if (digitalRead(2) == 0){
    wiegandOutput.setCharAt(index,0);
    index++;
  }
}
//interrupt Function
void readDATAONE(){
  if (digitalRead(3) == 0){
   wiegandOutput.setCharAt(index,1);
   index++
  } 
}

void setup(){
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  attachInterrupt(0, readDATAZERO, CHANGE);
  attachInterrupt(1, readDATAONE, CHANGE);
}

as you can see, I trying to read a RFID Wiegand Output

Ouch - it does seem like the String cannot be volatile.

I tweaked your code - changes have a <-- at end of line:

//volatile char wiegandOutput[27];        <-  
String wiegandOutput;
volatile byte index = 0;

//interrupt Function
void readDATAZERO(){
  if (digitalRead(2) == 0){
//    wiegandOutput.setCharAt(index,0);   <- 
    wiegandOutput.setCharAt(index,'\0');
    index++;
  }
}
//interrupt Function
void readDATAONE(){
  if (digitalRead(3) == 0){
   wiegandOutput.setCharAt(index,'\1');
//   index++                              <-
   index++;
  } 
}

wiegandOutput is no longer volatile, and changed (you had char, but the function setCharAt() is for String objects). The last index needed a semicolon, and you haven't set up your loop yet.

However, I don't know if you want to use a char or a string. A char would be simpler, if I understand it:

wiegandOutput.setCharAt(index,'\0');
wiegandOutput.setCharAt(index,'\1');

Becomes

wiegandOutput[index]='\0';
wiegandOutput[index]='\1';

You'd also likely be able to put volatile back in (although I haven't tested)

Hi again David, thanks for your anwser. I solve this problem using char(thanks for your advice).