Compile Error based on Arduino Library

Hi All,

I'm using OS X El Captain and have 10.6.7. When I go to compile my code I get the below error. Any ideas on why I would be receiving a compile error on an Arduino library?

/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp: In function 'int USB_RecvControl(void*, int)':
/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp:430:7: error: 'length' does not name a type
auto length = len;
^
/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp:431:8: error: 'length' was not declared in this scope
while(length)
^
/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp:435:8: error: 'recvLength' does not name a type
auto recvLength = length;
^
/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp:436:6: error: 'recvLength' was not declared in this scope
if(recvLength > 64){
^
/Library/Arduino15/packages/arduino/hardware/avr/1.6.10/cores/arduino/USBCore.cpp:442:31: error: 'recvLength' was not declared in this scope
Recv((u8*)d + len - length, recvLength);
^
exit status 1
Error compiling.

  • Please post the code that causes this error using code tags(</> button). If you're using any 3rd party libraries then post links to where you downloaded them, or say if you used Library Manager to install.
  • What do you have selected in Tools > Board?

If you replace the two incidences of 'auto' in the function USB_RecvControl() with 'int', then the code will compile.

tangesazen:
If you replace the two incidences of 'auto' in the function USB_RecvControl() with 'int', then the code will compile.

But why isn't auto working? I know who added those lines to the code and they definitely know their stuff. It would be better to track down the actual source of the problem and try to fix it rather than just putting a bandaid on it. Every time a new AVR core comes out those edits will need to be redone

There is nothing wrong with the original code which uses 'auto'. So it may be a bug with a new compiler version, or with a particular compiler option flag.

It will be resolved eventually. But in the meantime, if you change those two incidences of 'auto' to 'int', the code will behave exactly the same... except it will compile.

Have you been able to reproduce this issue tangesazen? It would be helpful to have a sketch that demonstrates the problem but I suspect zeroice may have gone MIA. I've tried some simple sketches using auto with no problems.

I got the same error today from the following sketch that was compiled successfully on February 25:

void setup() {
Serial.begin(115200); // open serial connection to USB Serial
//port (connected to your computer)
Serial1.begin(57600); // open internal serial connection to
//MT7688
pinMode(13, OUTPUT); // in MT7688, this maps to device
}

void loop() {
int c = Serial1.read();// read from MT7688
if (c != -1) {
switch(c) {
case '0': // turn off D13 when receiving "0"
digitalWrite(13, 0);
break;
case '1': // turn on D13 when receiving "1"
digitalWrite(13, 1);
break;
}
}
}

kevinwlu:
I got the same error today from the following sketch that was compiled successfully on February 25:

  • Which Arduino IDE version are you using?
  • What do you have selected in Tools > Board?