(SOLVED) IDE Compilation errors associated with sketch name !!

Update:
I had another file in the same directory named PulseTestCode - Copy2.ino. Apparently any .ino file in the sketch directory is brought into the compilation process. So renaming it PulseTestCode - Copy2.ino.old solved the problem.


I’ve experienced a curious problem with IDE 1.8.5 (the only one I’ve been using).

I’m working on a sketch to measure a pulse (see code) I’ve been copying it between two machines, both withe IDE 1.8.5. One machine has a nice screen and keyboard, the other does not but is connected to the hardware. I’ve been doing this for a couple of days with no issues.

Now the freaky part…
First thing this morning I made a simple change (added a delay), when I tried to verify the code I received numerous errors. See 2nd “code” window. I could not find the error so in desperation I copied the whole sketch (Ctrl C / Ctrl V) and pasted it into a new IDE window and gave it a different name. It now compiled fine!!

I have deleted all the arduino files in “C:\Users\john\AppData\Local\Temp\arduino_build_xxxxxx”
Rebooted… error still existed (only when using the original filename)

I searched my C: drive for any file containing the same name as the problem file. none found other than the project file.

Its not stopping me as I simply change the name, but I’d be curious if anyone else has run into this.

// Pulse trial code  v0.108

#include "Arduino.h"
#include <avr/interrupt.h>
#define trigger_pin A0  	//A0, PORTC0 - this pin is not needed for Radio.
#define echo_pin 8      	//ProMini Terminal 8, PORTD8 - used as input to ICP1 (capture)
#define LED 13

// *** these variables are global because they are declared prior to the setup() section

volatile int8_t rising;
volatile uint16_t gRiseCnt;
volatile uint16_t gFallCnt;

void setup() {
  /* cli();
     CLKPR=0x80;
     CLKPR=0x04;    // enable change then change sys clock prescaler  (0x04 = รท16)
     sei();
  */
  // *** Timer 1 Setup ***
  //PRR &= ~(1 << PRTIM1);    		//enable Timer 1 in power register (not req'd, PRR defaults to all 0's)
}
.
.
.
.
.

Errors reported.

Arduino: 1.8.5 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"


Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\john\AppData\Local\Temp\arduino_build_885715\sketch\PulseTestCode.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\john\AppData\Local\Temp\arduino_build_885715\sketch\PulseTestCode.ino.cpp" -o "C:\Users\john\AppData\Local\Temp\arduino_build_885715\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\john\AppData\Local\Temp\arduino_build_885715\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\john\AppData\Local\Temp\arduino_build_885715\sketch\PulseTestCode.ino.cpp" -o "C:\Users\john\AppData\Local\Temp\arduino_build_885715\sketch\PulseTestCode.ino.cpp.o"
C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode - Copy.ino:13:17: error: redefinition of 'volatile int8_t rising'

 volatile int8_t rising;

                 ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode.ino:14:17: note: 'volatile int8_t rising' previously declared here

 volatile int8_t rising;

                 ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode - Copy.ino:14:19: error: redefinition of 'volatile uint16_t gRiseCnt'

 volatile uint16_t gRiseCnt;

                   ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode.ino:15:19: note: 'volatile uint16_t gRiseCnt' previously declared here

 volatile uint16_t gRiseCnt;

                   ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode - Copy.ino:15:19: error: redefinition of 'volatile uint16_t gFallCnt'

 volatile uint16_t gFallCnt;

                   ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode.ino:16:19: note: 'volatile uint16_t gFallCnt' previously declared here

 volatile uint16_t gFallCnt;

                   ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode - Copy.ino: In function 'void setup()':

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode - Copy.ino:17:6: error: redefinition of 'void setup()'

 void setup() {

      ^

C:\Users\john\Documents\Arduino\PulseTestCode\PulseTestCode.ino:18:6: note: 'void setup()' previously defined here

 void setup() {

      ^


exit status 1
Error compiling for board Arduino Pro or Pro Mini.

I have just copied the code with the same name(PulseTestCode), and another name, and it has compiled perfectly(and the same version: IDE 1.8.5)It may be a windows error because in my ubuntu worked :o