error: expected declaration or statement at end of input in 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.

8

7 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.

8

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.

You probably have syntax error. You most likely forgot to put a } or ; somewhere above this function.

2

For me it was a missing } bracket in a function called by the code where the error was reported. Was also reported on code calling the function that called the function missing the }. So can be hard to find if you do not know what you are looking for.

Try to place a

return 0;

on the end of your code or just erase the

void

from your main function I hope that I helped

For me I just noticed that it was my .h archive with a '{'. Maye that can help someone =)

for anyone who tries to run a mpi program and gets the error above, deleting commends right before or after these symbols { } seem to do the trick.

I have both kali and ubuntu wsl, in kali the program runs fine but in ubuntu i had to delete the comments in order for the program to run

1

You Might Also Like