Previously working arduino sketch does not compile any more

Dear Arduino Community,

I would kindly like to ask for your help on this conundrum that I face. My sketch used to work perfectly on a previous version of IDE, but after upgrading it to IDE 1.6.5-r5-windows, my sketch does not even compile.

The problem seems to be with a function that returns a structure. Once I comment this out it works fine.

Please see below the problematic function:

  typedef struct{
  uint16_t bin0;
  uint16_t bin1;
  uint16_t bin2;
  uint16_t bin3;
  uint16_t bin4;
  uint16_t bin5;
  uint16_t bin6;
  uint16_t bin7;
  uint16_t bin8;
  uint16_t bin9;
  uint16_t bin10;
  uint16_t bin11;
  uint16_t bin12;
  uint16_t bin13;
  uint16_t bin14;
  uint16_t bin15;

    // Mass Time-of-Flight
    float bin1MToF;
    float bin3MToF;
    float bin5MToF;
    float bin7MToF;

    // Sample Flow Rate
    float sfr;

    // Either the Temperature or Pressure
    unsigned long temp_pressure;

    // Sampling Period
    float period;

    // Checksum
    unsigned int checksum;

    float pm1;
    float pm25;
    float pm10;
}HistogramData;


HistogramData hist;




void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
hist= read_histogram();
}




HistogramData read_histogram()
{
  // Read the Histogram Data and reset the histogram, return the struct
  // $ alpha.read_histogram()
  
  HistogramData data;
  byte vals[62];

  // Read the data and clear the local memory
  digitalWrite(SS, LOW);       // Pull the SS Low
  SPI.transfer(0x30);                 // Transfer the command byte
  digitalWrite(SS, HIGH);

  delay(12);                          // Delay for 12 ms

  // Send commands and build array of data
  digitalWrite(SS, LOW);

  for (int i = 0; i < 62; i++){
      vals[i] = SPI.transfer(0x30);
      delayMicroseconds(4);
  }

  digitalWrite(SS, HIGH);      // Pull the SS High

  data.period = _calculate_float(vals[44], vals[45], vals[46], vals[47]);
  data.sfr    = _calculate_float(vals[36], vals[37], vals[38], vals[39]);

 

  // Calculate all of the values!
  data.bin0   = _16bit_int(vals[0], vals[1]);
  data.bin1   = _16bit_int(vals[2], vals[3]);
  data.bin2   = _16bit_int(vals[4], vals[5]);
  data.bin3   = _16bit_int(vals[6], vals[7]);
  data.bin4   = _16bit_int(vals[8], vals[9]);
  data.bin5   = _16bit_int(vals[10], vals[11]);
  data.bin6   = _16bit_int(vals[12], vals[13]);
  data.bin7   = _16bit_int(vals[14], vals[15]);
  data.bin8   = _16bit_int(vals[16], vals[17]);
  data.bin9   = _16bit_int(vals[18], vals[19]);
  data.bin10  = _16bit_int(vals[20], vals[21]);
  data.bin11  = _16bit_int(vals[22], vals[23]);
  data.bin12  = _16bit_int(vals[24], vals[25]);
  data.bin13  = _16bit_int(vals[26], vals[27]);
  data.bin14  = _16bit_int(vals[28], vals[29]);
  data.bin15  = _16bit_int(vals[30], vals[31]);

  return data;
}

The problem arises when I define this function. Do you have any idea what could be the source of this problem??

Please also find attached the complete code.

Looking forward for your insight!

Thank you,

Panayiota.

OPC-N2_test_functions_16_06_GPS_complete_code.ino (8.79 KB)

Win 10, IDE version 1.8.5. There are a bunch of warnings but the attached code complies for me. What error(s) are you getting. Post the entire error message(s).

Dear groundFungus,

Thank you for your reply! Indeed, I also installed IDE 1.8.6 and surprisingly it works on this IDE version. I just cannot understand why it doesn't compile on IDE 1.6.5-r5.

The errors I get are:

Arduino: 1.6.5 (Windows 8.1), TD: 1.41, Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all



C:\Users\p.antoniou\AppData\Roaming\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\p.antoniou\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino -IC:\Users\p.antoniou\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\standard C:\Users\PAA54~1.ANT\AppData\Local\Temp\build1426606321795153282.tmp\error_function_that_returns_struct.cpp -o C:\Users\PAA54~1.ANT\AppData\Local\Temp\build1426606321795153282.tmp\error_function_that_returns_struct.cpp.o 

error_function_that_returns_struct.ino:5:1: error: 'HistogramData' does not name a type
error_function_that_returns_struct.ino: In function 'void loop()':
error_function_that_returns_struct.ino:56:22: error: 'read_histogram' was not declared in this scope
error_function_that_returns_struct.ino: In function 'HistogramData read_histogram()':
error_function_that_returns_struct.ino:72:3: error: 'SPI' was not declared in this scope
error_function_that_returns_struct.ino:87:72: error: '_calculate_float' was not declared in this scope
error_function_that_returns_struct.ino:93:44: error: '_16bit_int' was not declared in this scope
'HistogramData' does not name a type

Thanks again!!