Compiling conflicting declaration 'byte second

I am using an Arduino UNO.
I am building a RTC that can be set with two push buttons (Pin 2 & 3 using pull-up resistors for low level logic) and this is used with a data logger.
I am using a DS3231 RTC and a MicroSD Card Adapter for the data logger.
I want to use the RTC program that I snipped from the internet. The RTC works well. I want to be able to set the clock later for daylight savings time without re-uploading the time change using the computer.
I also have included a K thermocouple analog sensor to A0.

I want to be able to data log and time stamp onto a micro SanDisk the date, time, and temperature when I make Pin 4 HIGH. I just want one line of data to be logged to the disk each time Pin 4 goes HIGH.
I have combined this RTC code again with Data Logging code that I have snipped from the internet.
I can get the serial communication with the serial monitor and it is printing the date, time and temperature in both C and F every second.

The problem I am having is that the data logger program uses a #define ECHO_TO FILE 0 and #define ECHO_TO_SERIAL 1 in the declaration at the top of the program before void setup(). The program will display the date and time and temp both C & F to the serial monitor. But when I change #define ECHO_TO_FILE 1, I get a compiling “Copy error message” conflicting declaration ‘byte second’. This occurs at line (byte i, second, minute, hour, day, date, month, year; which occurs under void setup () of the RTC code.

I cannot determine if I can get the data logger to work without being able to change #define ECHO_TO FILE 1.

I cannot get a timestamp to the data logger without ECHO_TO_FILE being set to 1.

Is there a code fix for this so that I can log on one line the date time and temperature C & F to teh data logger San Disk every time Pin 4 goes high.

I think I am close, but cannot seem to get past the above issue.

I would appreciate any help or suggestions to my code attached.

RTC_w_DATA_Logger_sketch.ino (11.1 KB)

You are missing a closing curly bracket } for the if / else statement in setup() . This is contained within the conditional code that only gets compiled when ECHO_TO_FILE is true (set to 1).

void setup() {

  Serial.begin(9600);
  Wire.begin();


  RTC.begin();
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home (); // go home on LCD
  lcd.begin(16, 2);

  int year, month, day, hour, minute, second, temperatureC, temperatureF;

  pinMode(2,  INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT);
  pinMode(10, OUTPUT);

#if ECHO_TO_SERIAL
  Serial.println("Write to serial port.");
  Serial.println("year,month,day,hour,minute,temperatureC,temperatureF");
#endif //ECHO TO SERIAL
#if ECHO_TO_FILE

  Serial.print("Initalizing SD Card...");
  if (!SD.begin(10)) //(CS_Pin))
  {
    Serial.println("Card failed, or not present");
    return;
  }
  else
  {
    Serial.println("Card Initalized");
    char filename[] = "TEMPBP.csv";
    logfile = SD.open(filename, FILE_WRITE);
    if (!logfile)
    {
      Serial.println("Could not create file");
      return;
    }
    else
    {
      Serial.print("Logging to: "); Serial.println(filename);
    }
    logfile.println("year,month,day,hour,minute,second,temperatureC,temperatureF");
  // <<<< no closing bracket for the "else" statement
#endif // ECHO_TO_FILE
    Wire.begin();
    RTC.begin();

  }  // <<<< this should be the closing bracket for setup(), but instead is matched with the if / else statement