Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: expected declaration or statement at end of input in c

Tags:

c

void mi_start_curr_serv(void){ #if 0  //stmt #endif     } 

I'm getting an error as "error: expected declaration or statement at end of input" in my compiler. I could not find any error with the above function. Please help me to understand this error.

like image 364
Angus Avatar asked Jan 03 '12 04:01

Angus


People also ask

How do you solve error expected declaration or statement at end of input?

For me this problem was caused by a missing ) at the end of an if statement in a function called by the function the error was reported as from. Try scrolling up in the output to find the first error reported by the compiler. Fixing that error may fix this error.

What is expected declaration error?

'Expected declaration` basically means that you should have defined something before using it. There are multiple fixes to this error: If you are trying to declare a variable or constant, be sure that you have a let or var at the beginning.

What does error expected before token mean?

The error: expected ')' before ';' token may occur by terminating the statements which should not be terminated by the semicolon. Consider the given example, here I terminated the #define statement by the semicolon, which should not be terminated.


1 Answers

Normally that error occurs when a } was missed somewhere in the code, for example:

void mi_start_curr_serv(void){     #if 0     //stmt     #endif 

would fail with this error due to the missing } at the end of the function. The code you posted doesn't have this error, so it is likely coming from some other part of your source.

like image 52
DRH Avatar answered Sep 19 '22 13:09

DRH