Go Down

Topic: Mysterious IDE Behavior (Read 109 times) previous topic - next topic

pgsmick

Hi all,

I am not very fluent in using the Arduino IDE library system and the following behavior is mystifying me.

For some years now I have been developing my Arduino projects using NANO boards and have now begun to look at the STM32F103 BluePill boards.  I believe that I have installed everything I need, and so far every "NANO" sketch I have tried to adapt to the BluePill has worked fine.  These include sketches that use AccelStepper and OLED displays, and the related libraries.


One of my sketches that has been working fine with the NANO uses the EEPROM library to support a number of EEPROM.get, .put and .write calls.   However, when I try to compile such a sketch after specifying the STM32 board, I get a pile of error messages like so:

Code: [Select]
Arduino: 1.8.13 (Windows 10), Board: "Generic STM32F1 series, BluePill F103CB (or C8 with 128k), HID Bootloader 2.2, Enabled (generic 'Serial'), CDC (generic 'Serial' supersede U(S)ART), Low/Full Speed, Smallest (-Os default), Newlib Standard"

In file included from P:\Arduino\FuelGauge-STM32\FuelGauge_STM32_V1\FuelGauge_STM32_V1.ino:31:

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:34:1: error: expected unqualified-id before 'struct'

   34 | struct EERef {

      | ^~~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:157:3: error: 'EERef' does not name a type

  157 |   EERef operator*()

      |   ^~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:194:3: error: 'EERef' does not name a type

  194 |   EERef operator[](const int idx)

      |   ^~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h: In member function 'uint8_t EEPROMClass::read(int)':

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:200:12: error: 'EERef' was not declared in this scope

  200 |     return EERef(idx);

      |            ^~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h: In member function 'void EEPROMClass::write(int, uint8_t)':

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:204:6: error: 'EERef' was not declared in this scope

  204 |     (EERef(idx)) = val;

      |      ^~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h: In member function 'void EEPROMClass::update(int, uint8_t)':

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:208:5: error: 'EERef' was not declared in this scope

  208 |     EERef(idx).update(val);

      |     ^~~~~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h: In member function 'T& EEPROMClass::get(int, T&)':

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:231:16: error: no match for 'operator*' (operand type is 'EEPtr')

  231 |       *ptr++ = *e;

      |                ^~

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h: In member function 'const T& EEPROMClass::put(int, const T&)':

C:\Users\Peter\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\libraries\EEPROM\src/EEPROM.h:241:8: error: no match for 'operator*' (operand type is 'EEPtr')

  241 |       (*e).update(*ptr++);

      |        ^~

exit status 1

Error compiling for board Generic STM32F1 series.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.



HOWEVER, on the very same Windows machine, and without making any settings changes,  when I open any of the EEPROM example sketches found under Examples for Generic STM32F1 Series, they compile without error and run fine.  When I compare my code to the example code, I see the same syntax being used for including the library, namely: #include <EEPROM.h> and the same syntax being used to make the EEPROM calls.

I get the same behavior on both Windows machines I use for development.

So what am I missing?  How do I correct whatever I haven't done properly?

Many thanks in advance,
Peter

pgsmick

I should add that the #include <EEPROM.h> statement by itself triggers the same errors with all the EEPROM calls commented out.

pgsmick

I worked around the problem, but I'm still interested in knowing what went on.

So I:

1.  Retrieved a simple EEPROM sketch from the Examples menu choosing one from the Examples for Generic STM32 F103 Series.

2.  Stripped out all the code from the sketch leaving only the #include statement and empty setup() and loop() functions.  I verified that this stripped down example would compile.

3.  Retrieved my sketch that would not compile and Ctrl-C copied all the code.

4.  Pasted the code into a text editor and commented out all references to EEPROM including the #include statement and all the calls to the EEPROM library.

5.  Copied all the code from the text editor and pasted into the stripped-down example.

6.   Removed the empty setup() and loop() functions, and the result compiled successfully.

At step 3, if I pasted the code directly from the Arduino IDE and into the stripped-down example sketch, the result would not compile.  I had to do it by way of the text editor.

From all this, especially the unexpected result when I pasted code from one sketch to the other within the IDE. I conclude that the Arduino IDE is doing something behind the scenes that I would really like to understand so I can avoid this nonsense in the future.

Any thoughts to this development?
 

Go Up