HI, Had a problem with the IDE. Create a new sketch main file (xx.ino) and added other other files (xx.h and xx.c). Then complied. Got an error "class not recognise did I mean ..."! This confused me for a while, anyway long story short I noted that the compiler needs the source file to be a xx.cpp for classes etc. Yeah, ok that's correct. No problem, I changed the file extension from xx.c to xx.cpp and recompiled. Still the same problem? Gave the same error message pointing to a location in the source file classed "xx.c"! What?!? That file does exist in the folder! Now very confused, after much mucking around I found that if I started a new sketch with the same files (all renamed to cpp) the sketch compiled fine.
It seems the IDE does not reread the file types once in the sketch, even if they change?
My question, is there anyway to force the IDE to reread the file types in a sketch?
The Arduino developers are tracking this bug here:
You can do it by deleting the temporary build folder where the zombie file is still stored . I'll provide instructions you can follow to do that:
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compilation" in the "Preferences" dialog.
Click the "OK" button.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to finish.
Examine the contents of the black "Output" panel at the bottom of the Arduino IDE window. You will see the temporary sketch build folder in the compilation commands there.
For example, if you saw this line of output:
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\per\\AppData\\Local\\Temp\\arduino\\sketches\\44903AA428159DEA0A2322AB6B3CD206/sketch_jan14a_copy_20240119071329.ino.elf"
Delete the temporary build folder.
The folder may be hidden by default in your file manager and terminal.
Please be careful when deleting things from your computer. When in doubt, back up!
Now compile the sketch again. Arduino IDE regenerates the build folder if it is not present, so deleting the folder doesn't do any harm and will result in the zombie file being purged.