does not name a type

I have this sketch which refuses to compile. can anybody point me towards my mistake?
the error is 'manualAdvance' does not name a type.

const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
int relayPin = 8;
int syncPin = 9;
int testPin = 10;
const int retardPin = 2;
const int advancePin = 3;
int retardState = 0;
int advanceState = 0;
//char summerTime = bitRead(receivedChars[12],1);
byte summerTime = bitRead(receivedChars[12], 1); //will intialize as 0 winterTime

boolean relayRunning = false;
unsigned long relayStartTime = 0;
unsigned long lastRelayStartTime = 0;
byte missedCount = 0;
boolean summerAdvance = false;
boolean winterRetard = false;
boolean missedPulseAdvance = false;
boolean manualAdvance = false;

byte seconds = 0;

void setup() {

  Serial.begin(9600);
  Serial.println("Arduino is ready --");
  pinMode(relayPin, OUTPUT);
  pinMode(syncPin, OUTPUT);
  pinMode(testPin, OUTPUT);
  pinMode(retardPin, INPUT_PULLUP);
  pinMode(advancePin, INPUT_PULLUP);
  //bitRead(receivedChars[12],1); not useful here before message arrives
}

void loop() {

  recvWithStartEndMarkers();

  retardState = digitalRead(retardPin);
  advanceState = digitalRead(advancePin);
  
  
 if (newData == true)
    processNewData();
  if (relayRunning == true && summerAdvance == false && winterRetard == false && missedPulseAdvance == false && manualAdvance == false)
    runRelayCycle();
  if bitRead(receivedChars[12], 1==1)
    digitalWrite (testPin, HIGH);
    else digitalWrite (testPin, LOW);
  if bitRead(receivedChars[12], 2==1)
    digitalWrite (syncPin, HIGH);
    else digitalWrite (syncPin, LOW);
  if (summerAdvance == true)
    advanceClock(124); // 1 hour  each pulse advances slave 30 seconds
  if (winterRetard == true)
    retardClock(1); //11 hours advance = 1 hour back
  if (manualAdvance == true)
    manualAdvanceClock;  
  //if (missedPulseAdvance == true)
   // advanceClock(missedCount);
}

void recvWithStartEndMarkers() {
  static boolean recvInProgress = false;
  static byte ndx = 0;
  char startMarker = 0x02;
  char endMarker = 0x03;
  char rc;

  if (Serial.available() > 0) {
    rc = Serial.read();

    if (recvInProgress == true) {
      if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
          ndx = numChars - 1;
        }
      }
      else {
        receivedChars[ndx] = '\0'; // terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }

    else if (rc == startMarker) {
      recvInProgress = true;
    }
  }
}

void processNewData()
{
  //if (newData == true)
  //{
    checkStatusBit();

    if ((receivedChars[1] == '3' && receivedChars[0] == '0') || (receivedChars[1] == '0' &&
        receivedChars[0] == '0'))
    {
      if (relayRunning == true)//set true during fast advance
      {
        missedCount++;
        Serial.print("missedCount = ");
        Serial.println(missedCount);
      }

      if (relayRunning == false) //back to normal from fast advance
      {
        relayStartTime = millis();
        if((relayStartTime - lastRelayStartTime >= 14000)&&(retardState == HIGH)) //some lock out period
        {
          digitalWrite (relayPin, HIGH);
          relayRunning = true;
          lastRelayStartTime = relayStartTime;
         }
        //if (missedCount > 0)
        //{
          //missedPulseAdvance = true; //make up pulses next loop pass
        //}
        //digitalWrite (relayPin, HIGH);
        //relayRunning = true;
        //relayStartTime = millis();
        
        Serial.println("on");
      }
    }

    Serial.print("Time Now ... ");
    Serial.print(bitRead(receivedChars[12], 1));
    Serial.print(bitRead(receivedChars[12], 2));
    Serial.print(receivedChars[5]);
    Serial.print(receivedChars[4]);
    Serial.print(receivedChars[3]);
    Serial.print(receivedChars[2]);
    Serial.print(receivedChars[1]);
    Serial.println(receivedChars[0]);
    newData = false;
 // }
}

void runRelayCycle()
{
  const unsigned long relayInterval = 400;
  //if (relayRunning == true && millis() - relayStartTime >= relayInterval)
  if (millis() - relayStartTime >= relayInterval)
  {
    digitalWrite(relayPin, LOW);
    relayRunning = false;
  }
}

void advanceClock(unsigned int numberOfPulses)
{
  const unsigned long intervalOn = 400; //adjust these numbers for fastest reliable advance
  const unsigned long intervalOff = 600;
  static byte relayState = LOW;//initial state starts off
  static unsigned long interval = intervalOff;
  static unsigned long previousMillis = millis();
  static unsigned int fastCount = 0;
  relayRunning = true;//blocks regular 30 second pulses
  unsigned long currentMillis = millis();
  //interval switchs between intervalOn and intervalOff
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = millis();
    if (relayState == LOW)
    {
      relayState = HIGH;
      digitalWrite(relayPin, relayState);
      interval = intervalOn; //switch interval
    }
    else //relay was HIGH
    {
      relayState = LOW;
      digitalWrite(relayPin, relayState);
      interval = intervalOff;
      fastCount++; //count at end of pulse
      Serial.println(fastCount);
      
    }
  }
  if (fastCount >= numberOfPulses)
  {
    fastCount = 0;
    interval = intervalOff;
    summerAdvance = false;
    winterRetard = false;
    manualAdvance = false;
    if (missedPulseAdvance == true)
    {
      missedPulseAdvance = false;
      missedCount = 0;
    }
    relayRunning = false;
  }
}


  
void retardClock(unsigned int numberOfPulses)
{
  const unsigned long intervalOn = 0; //adjust these numbers for fastest reliable advance
  const unsigned long intervalOff = 3600000;
  static byte relayState = LOW;//initial state starts off
  static unsigned long interval = intervalOff;
  static unsigned long previousMillis = millis();
  static unsigned int fastCount = 0;
  relayRunning = true;//blocks regular 30 second pulses
  unsigned long currentMillis = millis();
  //interval switchs between intervalOn and intervalOff
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = millis();
    if (relayState == LOW)
    {
      relayState = HIGH;
      digitalWrite(relayPin, relayState);
      interval = intervalOn; //switch interval
    }
    else //relay was HIGH
    {
      relayState = LOW;
      digitalWrite(relayPin, relayState);
      interval = intervalOff;
      fastCount++; //count at end of pulse
      Serial.println(fastCount);
    }
  }
  if (fastCount >= numberOfPulses)
  {
    fastCount = 0;
    interval = intervalOff;
    summerAdvance = false;
    winterRetard = false;
    manualAdvance = false;
    if (missedPulseAdvance == true)
    {
      missedPulseAdvance = false;
      missedCount = 0;
    }
    relayRunning = false;
    //Serial.println("relayRunning = false");
  }
}

void manualAdvanceClock(unsigned int numberOfPulses)
{
  const unsigned long intervalOn = 400; //adjust these numbers for fastest reliable advance
  const unsigned long intervalOff = 600;
  static byte relayState = LOW;//initial state starts off
  static unsigned long interval = intervalOff;
  static unsigned long previousMillis = millis();
  static unsigned int fastCount = 0;
  relayRunning = true;//blocks regular 30 second pulses
  unsigned long currentMillis = millis();
  //interval switchs between intervalOn and intervalOff
  if (currentMillis - previousMillis >= interval)
  {
    previousMillis = millis();
    if (relayState == LOW)
    {
      relayState = HIGH;
      digitalWrite(relayPin, relayState);
      interval = intervalOn; //switch interval
    }
    else //relay was HIGH
    {
      relayState = LOW;
      digitalWrite(relayPin, relayState);
      interval = intervalOff;
      fastCount++; //count at end of pulse
      Serial.println(fastCount);
    }
  }
}

void checkStatusBit()
{
  static byte lastSummerTime = 0; //initialize for winterTime
  summerTime = bitRead(receivedChars[12], 1);
  if (summerTime == 1 && lastSummerTime == 0)//state change
  {
    summerAdvance = true;
    lastSummerTime = summerTime; //set to 1
  }

  if (summerTime == 0 && lastSummerTime == 1)//state change
  {
    winterRetard = true;
    lastSummerTime = summerTime; //set to 0
  }
}

void checkAdvancePin()
{
  if (advanceState == HIGH);
}
      manualAdvance = true;
  }
  else
  {
    manualAdvance = false;
    
  }
}

Try using auto-format. CTRL-T

This is often the best way to find mismatched curly brackets, which is causing your issue in checkAdvancePin()

Edit: More accurately -

 if (advanceState == HIGH);

I don't think you want the semicolon there (and fix your curly bracket problem)

Also post the full error message, so that we can know which is the offending line.

Vince already spotted the error, a corrupt bracket structure in checkAdvancePin(). This function also can be rewritten into simply
void checkAdvancePin()
{
manualAdvance = advanceState;
}

I personally don't like comparisons of boolean variables against true or false, what often can introduce unexpected behaviour.

I personally don't like comparisons of boolean variables against true or false, what often can introduce unexpected behaviour.

Why ? A boolean variable can only have a value of true or false

Right, that's why if (boolvar) stands for if (boolvar == true), and if (!boolvar) ...

DrDiettrich:
Right, that's why if (boolvar) stands for if (boolvar == true), and if (!boolvar) ...

So what is the unexpected behaviour that is often introduced that you mention in post #2 ?

These puzzle me

  if bitRead(receivedChars[12], 1==1)
..    
..
  if bitRead(receivedChars[12], 2==1)

for more reasons than one.

UKHeliBob:
So what is the unexpected behaviour that is often introduced that you mention in post #2 ?

Bogus may happen if you mix or confuse true and HIGH or 1 in comparisons, or = and ==.

DrDiettrich:
Bogus may happen if you mix or confuse true and HIGH or 1 in comparisons, or = and ==.

In practice the program will work fine using HIGH or 1 in testing for true but I agree that it could be confusing.

However, what you said was

I personally don't like comparisons of boolean variables against true or false, what often can introduce unexpected behaviour.

Did you actually mean what you wrote ?

Yes, I mean it as I wrote. Boolean values deserve no comparison, they can be used as they are. C even allows to use any integral value without a comparison - zero means false, everything else means true.

Boolean values deserve no comparison

I believe that you mean that boolean values do not need any comparison, which is true. However, that does not mean that there is a problem using == or != to test their value.

What is true is that use of = where == should be used is a problem, as it is for any data type, but I would expect anyone who understands that if (booleanVariable) is equavalent to if (booleanVariable == true) to know the difference between = and ==

AWOL:
These puzzle me

  if bitRead(receivedChars[12], 1==1)

..   
..
  if bitRead(receivedChars[12], 2==1)


for more reasons than one.

Extracting a particular bit from a byte to perform a function.

thanks for the help :wink:

steve37264:
Extracting a particular bit from a byte to perform a function.

thanks for the help :wink:

Ok, right.
Thanks for the clarification.
Good luck.