ERROR: expected constructor, destructor, or type conversion before '(' token

The error is on the second pinMode function, and when I swapped the order of them is was still on the bottom one. Any ideas?

const int powerPin = 7;
const int testPin = 8;

pinMode(testPin, INPUT);
pinMode(powerPin, OUTPUT); // This sets the power pin to be an output. This must be done in order to be able to use it as an output, and the same for an input.

void setup() {
  // put your setup code here, to run once:

digitalWrite(powerPin, HIGH); // This sets the output of the pin to "High", which is full. The digitalWrite command has two settings: HIGH, and LOW
delay(1000);
digitalWrite(powerPin, LOW);
delay(1000);

analogWrite(powerPin, 125);
delay(1000);
analogWrite(powerPin, 255);
delay(1000);
analogWrite(powerPin, 125);
delay(1000);
analogWrite(powerPin, 0);
delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:

analogRead(testPin) = brightness;

  if (brightness < 255)
    {
      analogWrite(powerPin, brightness++); // This says that if the brigtness is less than the highest, add 1 to the output and try again.
    }
  else
    {
      analogWrite(powerPin, brightness-=255); // Else (so when brightness is 255), subtract 255 from it and set that as the output. 
    }
}

pinMode() needs to be inside setup() and before any read() write() to that pin

arduino_new:
pinMode() needs to be inside setup() and before any read() write() to that pin

Thanks! That fixed the issue, but why would the first "pinMode" not be detected as an error, only the second?

SeveredGrape:
Thanks! That fixed the issue, but why would the first "pinMode" not be detected as an error, only the second?

I'm sure they did show it, you just missed to read the whole thing.