Serial.readBytes() gives different return value on different board.

So I got this code:

byte buf[12];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available()) {
    Serial.readBytes(buf, 12);
  }  
}

When compiling on Arduino MKR1010 (or any of the MKR family), I got this error:
invalid conversion from ‘byte* {aka unsigned char*}’ to ‘char*’ [-fpermissive]

This does not happen if I compile it on an UNO, Nano… Is there a workaround on this one? It would be neat if I can keep the buf variable to be byte type.

    Serial.readBytes((char*)buf, 12);
char buf[12];

Thanks for the reply but I would want my buf to be of type byte, since I have a system where the RPI would send byte data to the Arduino. If changing the type of buf to be of char, all the data would mess up.

A char is just a byte. It may be a signed byte but that makes no difference until you print them.

MorganS: A char is just a byte. It may be a signed byte but that makes no difference until you print them.

But the range of a char is different from a byte though. If I send a byte with the value of 255, having the char as the receiver type will convert that value to a negative number.

It doesn't "convert" until a human looks at it. The bit pattern is the same.