error: a function-definition is not allowed here before '{' token

I’ve been working on a school project that involves sending sensor data to ThingSpeak for MATLAB processing.
Code was compiling totally fine the night before, and I open it to start working on it today and its giving me an error usually associated with missing { or }s. I’ve gone through my entire code and can’t seem to find any misplaced brackets, so I’ve got no clue why I’m getting this error. Any help would be greatly appreciated.

//Setup
void setup() {
  // Begin Hardware Serial for debugging
  Serial.begin(9600);
  while (!Serial);
  Serial.print("Sketch:   ");   Serial.println(__FILE__);
  Serial.print("Uploaded: ");   Serial.println(__DATE__);

  
  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);

  ThingSpeak.begin(client); //Initialize ThingSpeak
  //Configure Pins

  //SETUP GPS???
  ss.begin(9600);   //Online spec sheet says 9600, try 38400? or 4800

  //Initialize SD card
  Serial.print("Initializing SD card...");
  if (!SD.begin(sdPin)) {
    Serial.println("...initialization failed.");
  }
  else {
    Serial.println("...initialization done.");
  }
  //Begin file that logs how many times dataDumps have
  //occured, and ensure it opened
  dumpCount = SD.open("dumpCount.txt", FILE_WRITE);
  if (dumpCount) {
    Serial.println("Initializing dumpCount.txt");
    dumpCount.println("1");
    dumpCount.println("1");
    dumpCount.close();
    Serial.println("file dumpCount.txt created.");
  }
  else {
    Serial.println("error opening dumpCount.txt.");
  }
}

void loop() {
  //Variables
  int count = 0;
  unsigned long connectionTime;
  bool connectionStatus = true;
  //Check storage, Check if time requires upload (every 60 seconds?)

  //If full or need to upload, try and offload data
  if (millis() - lastSend >= updateThingSpeakInterval) {
    //Check LOCATION GPS****
    //For one second, parse GPS data
    bool newData = false;
    while (newData = false) {
      for (unsigned long start = millis(); millis() - start < 1000;) {
        while (ss.available()) {
          char c = ss.read();
          //send raw data to the terminal window (uncomment if you want to see raw data
          //Serial.write(c);
          if (gps.encode(c)) {
            newData = true;
          }
        }
      }
      //Get lon and lat
      float flat, flon;
      unsigned long age;
      gps.f_get_position(&flat, &flon, &age);
      //Calibration
      flat = (flat + 42) / 42; //CALIBRATION CORRECTION
      flon = (flon + 42) / 42; //CALIBRATION CORRECTION
      //****
      //Calculate avg value for dB over past minute
      soundAvg = soundAvg / count;
      
      //Check if last udpate was succesful
      if (uploadStatus == false) {
        uploadStatus = dataDump(); //Try to send SD file over to ThingSpeak
      }
      //If last update was succesful, or if dataDump was succesful, continue thingSpeak upload
      if (uploadStatus == true) {
        //Update ThingSpeak Fields
        ThingSpeak.setField(1, soundAvg); //Replace with value
        ThingSpeak.setField(2, soundMax); // ^^^
        ThingSpeak.setField(3, soundMin);
        ThingSpeak.setField(4, flat);
        ThingSpeak.setField(5, flon);
        //write to thingspeak channel
        int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
        if (x == 200) {
          lastSend = millis();  //Reset
          Serial.println("Channel update successful.");
          uploadStatus = true;
        }
        else { //Failed to upload to thingSpeak
          Serial.println("Problem updating channel. HTTP error code " + String(x));
          uploadStatus = false;
          storeSD(soundAvg, soundMax, soundMin, flat, flon, age, x);
        }
      }
      else { //If both previous upload and the dataDump were failures, store to SD
        Serial.println("Problem offloading SD card.");
        storeSD(soundAvg, soundMax, soundMin, flat, flon, age, DUMP_ERROR); //replace x with some other code for status
      }

      //Delete Data?

      //If cannot send data, store data??

      //Reset variables
      soundAvg = 0;
      count = 0;
      soundMax = 0;
      soundMin = 1000;  //Arbitrary large number
    }
    //If not full,
    //Check If location has changed?

    //Check sound sensor input
    soundOutput = analogRead(soundPin); //Read from analog
    soundDB = (soundOutput + 42) / 42;//Correction factors calculated from regression analysis calibration

    //Calculate average value
    soundAvg += soundDB;
    count ++;

    //Find max value
    if (soundDB > soundMax) {
      soundMax = soundDB;
    }
    //Find min value
    if (soundDB < soundMin) {
      soundMin = soundDB;
    }
  }
}

Here is part of the error message:

C:\Users\Aidan\OneDrive - Queen's University\Year 2\Term 1\APSC 200\P2\Arduino_Setup\Arduino_Setup.ino: In function 'void storeSD(float, float, float, float, float, long unsigned int, int)':

Arduino_Setup:98:14: error: a function-definition is not allowed here before '{' token

 void setup() {

              ^

Arduino_Setup:252:1: error: expected '}' at end of input

 }

I’m working on a header file that contains the function void storeSD, so that might be where the error is coming from? But I don’t really see how that would do it.

Also please excuse some of my comments, this is very much a work in progress and they might not fully line up or make sense.

UPDATE:

Feeling pretty stupid. Missed a } in the header file.

I can’t see any #include in your code.

I didn't paste in any of my #includes or #defines, my bad. I found the problem though, I was just missing a bracket in one of my header files.

Now take a close look at

    while (newData = false)

Is it comparing newData with the value of false or setting the value of newData to false ?