You have go to post the full compiler results: No where do no mention what processor your are using?
You have some syntax errors in your code:
Servo sonic; creates the object, do not type cast the (int)
Then you have distance = Servo sonic.read();
Do not put the object type of Servo on the same line as the read().
distance = sonic.read();
Here is an example: