This is probably a daft question but its beyond me at the moment
The code below in a library header compiles in 1.8.19 but throws the error below that in 1.0.6 - not sure why and keen to learn? Thanks
private:
uint8_t _address;
uint16_t readData(uint8_t pointer);
const double pow16 = pow(2, 16); // This line throws the error below
C:\Users\Me\Documents\Arduino\libraries\ClosedCube_HDC1010\src/ClosedCube_HDC1010.h:84: error: 'double pow(double, double)' cannot appear in a constant-expression
C:\Users\Me\Documents\Arduino\libraries\ClosedCube_HDC1010\src/ClosedCube_HDC1010.h:84: error: a function call cannot appear in a constant-expression
C:\Users\Me\Documents\Arduino\libraries\ClosedCube_HDC1010\src/ClosedCube_HDC1010.h:84: error: ISO C++ forbids initialization of member 'pow16'
C:\Users\Me\Documents\Arduino\libraries\ClosedCube_HDC1010\src/ClosedCube_HDC1010.h:84: error: making 'pow16' static
Hi @point5. I will point out that this isn't really a matter of IDE version, but rather of compiler version. The installation of Arduino IDE 1.0.6 includes version 4.3.2 of the avr-gcc compiler, which is used when compiling sketches for the boards of the "Arduino AVR Boards" platform also bundled with Arduino IDE. Compiling this code with that version of GCC produces the error you experienced. The reason why you aren't getting the error when compiling with Arduino IDE 1.8.19 is because the platform in use by that version of the IDE uses a newer version of GCC. As for the specific reason why the different versions of GCC treat this code differently, I don't have an answer for that.
Since a specific version of the compiler came with the Arduino IDE installation and there wasn't a user-friendly way to upgrade the platform or install other platforms, it is reasonable to associate a compiler version with a given Arduino IDE 1.0.x version. However, starting from Arduino IDE 1.6.2, the IDE version and platform versions have been decoupled through the introduction of Arduino Boards Manager. It was now possible for the user to update their boards platforms to any of the available versions and to install additional platforms which might use a different compiler altogether.
Although you might have difficulty finding a platform that uses such an antiquated version of GCC, if you did install such a platform via the Arduino IDE Boards Manager in Arduino IDE 1.8.19, you would get the same error from your code.
Thanks to you both for taking the time to explain, it sounds like I really need to keep up to date Thanks to ptillisch I should have a way to get my custom board working in the 1.8.x generations of IDE and my task of porting code will hopefully become much more straightforward.