compiler error ignorance

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I usually create new projects by hacking up older ones. Now that I have finished a new project the compiler halts on this error:

Quote:
error: expected declaration or statement at end of input

The line it points to is the last line of the main.c file. Could anyone tell me what condition would trigger such an error? I'm having trouble finding any information in the documentation.

Of course the old project I used as a template compiles just fine.....

Best regards,
Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It might help if we actually saw the code that is causing the error.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Possibly unbalanced braces??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Before I make people plough through half a dozen files of poorly written code, I was hoping this error points to a clearly defined problem.

I was thinking about the braces too, but can't spot the problem. The error being at the last line of code also smells a bit fishy. Could it be that errors in other source or include files would trigger an error at this location?

Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> The error being at the last line of code also smells a bit fishy.

No, the error is clearly about some misstructuring ("expecting ..."),
so it can only be detected at the end of the source file: the compiler
was expecting something there, but got EOF.

This could be caused by about anything that is located before this
point.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmmm ok, I'll go stare at the code some more when I get home tonight.

I did have a problem once where a compile error in the .c file was caused by a missing semicolon in a .h file. But this was on an IAR or some Pic compiler.

Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right, uhhhhm, I forgot a closing }
I think I get stupid after staring too long at code, I found it within two minutes now......

Thanks,
Igor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not to pick, but the two lines generally go hand in hand. You can have the latter without the first, but if you have the first, you are sure to have the latter. I've done this and continue to do it from time to time, fail to comment and structure code well. The end result is way more effort to get end result than if I would have just done it right to begin with. Getting stupid infront of computer is no way to make progress; for me it's usually the antiprogress.

Quote:
Before I make people plough through half a dozen files of poorly written code,

Quote:
I think I get stupid after staring too long at code,