I cannot get Serial.begin(9600); to work with this code

I did this code to have 8 Mhz clock output (it works fine)

const int freqOutputPin = 9; // OC1A output pin for ATmega32u4 (Arduino Micro)
const int ocr1aval = 0;

void setup()
{
pinMode(freqOutputPin, OUTPUT);

TCCR1A = ( (1 << COM1A0));

TCCR1B = ((1 << WGM12) | (1 << CS10));

TIMSK1 = 0;

OCR1A = ocr1aval;
}

void loop()
{

}

but when I try to add Serial.begin(9600); I get this error message now.

"Serial does not name type"

Where did you try to add the Serial.begin(9600)? Was it inside the curly brackets ({}) of your setup() function?

Post the code that gives the error.