I have a sketch that I’m working on where I define different behavior based on whatever board is currently selected (using the pins_arduino.h file). However, I’m noticing different behavior when I use the same code I would use normally but have the Due board selected. For example, let’s take a look at this code:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // declare variables for MEGA boards
int MEGA_READ_DPIN_CONFIG[] = {22,23,24,25,26,27,28,29,30,31};
#endif
#if defined(__SAM3X8E__) // declare variables for DUE boards
int DUE_READ_DPIN_CONFIG[] = {22,23,24,25,26,27,28,29,30,31};
#endif
The code is identical (with different array names). However, later in my code I have these two loops:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //set pin mode for MEGA boards
for(int i = 0; i < MEGA_READ_DPIN_CONFIG.length; i++){
pinMode(MEGA_READ_DPIN_CONFIG[i], INPUT);
}
#endif
#if defined(__SAM3X8E__) //set pin mode for DUE boards
for(int i = 0; i < DUE_READ_DPIN_CONFIG.length; i++){
pinMode(DUE_READ_DPIN_CONFIG[i], INPUT);
}
#endif
However, this is where I run into an error when I try to compile the sketch (see below)
Firefly_Firmata_DUE.ino: In function 'void Init()':
Firefly_Firmata_DUE.ino:132:45: error: request for member 'length' in 'DUE_READ_DPIN_CONFIG', which is of non-class type 'int [10]'
Error compiling.
If I comment out the if def function for the DUE board, everything compiles just fine. So, it seems like the compiler is getting hung up on the length of the array that I created for the DUE board. Does anyone know why this is happening? or how to fix it?