Sign in to follow this  
gamesneverdie

Errors in stdio.h?!

Recommended Posts

(First time on here, yay :) )

I've got a problem with my current project for practicing.

I was going through some of the Tutorials of Lazyfoo (This one: http://lazyfoo.net/SDL_tutorials/lesson32/index.php ). The sample source code at the bottom of the page works fine.

But it seems like I have hit a brickwall.
I have everything exactly the same, but in multiple source files (like in this article: http://lazyfoo.net/articles/article07/index.php ).

I have problems with the Uint32 which is in the class declaration of the "dot" as "void move(Uint32 deltaTicks);"
The Compiler says that Uint32 was not declared, although I thought it would have been by declaring it in the move() function.

My next errors are the ones in the attachment (They also occur when I delete the Uint32 part). They say that the library stdio.h has 3 errors in it,
but i cannot believe that's true, because the same library works with the program when it is not split into multiple sources.

Share this post


Link to post
Share on other sites
The first error you have is "[i]expected ',' or ';' before extern[/i]".

The compiler is telling you that you forgot to end a statement. It was expecting the end of a statement, but didn't find it.

Look for a missing semicolon on the line before you include stdio.h. If you are including one of your project's files before stdio, make sure the items in the header are properly terminated.

Share this post


Link to post
Share on other sites
[quote name='PoriKori' timestamp='1306180689' post='4814723']
I forgot to tell (and just checked again): I am not even including stdio.h in any of my files... I have no idea why this error is occuring.
[/quote]

Frob's point is still valid: some header that you're including is likely including stdio.h on its first line. Check all your own header files to make sure that they all have the requisite semicolon endings to their class and/or function declarations.

Share this post


Link to post
Share on other sites
[quote name='Narishma' timestamp='1306183666' post='4814739']
Uint32 is a typedef declared in SDL.h, so you have to include that to use it.
[/quote]
Thanks, that (almost) did it!
At least I'm not gettign errors in stdio.h or any Uint32 declaration errors anymore.
But I got a new error:
SDL_image.h: Line 34: expected ',' or ';' before 'extern'

@BCullis: I can't find any spots where I forgot the semicolon though.
And I'm not that experienced in programming/C++ so it sometimes puzzles me, why the compiler doesn't show me the line in my files instead of showing something in the standard libraries...

Edit:
Duh... found a missing semicolon. Thanks guys, I was sitting on this since yesterday. Everything works just fine now!

Share this post


Link to post
Share on other sites
[quote name='PoriKori' timestamp='1306184275' post='4814746']
[quote name='Narishma' timestamp='1306183666' post='4814739']
Uint32 is a typedef declared in SDL.h, so you have to include that to use it.
[/quote]
Thanks, that (almost) did it!
At least I'm not gettign errors in stdio.h or any Uint32 declaration errors anymore.
But I got a new error:
SDL_image.h: Line 34: expected ',' or ';' before 'extern'

@BCullis: I can't find any spots where I forgot the semicolon though.
And I'm not that experienced in programming/C++ so it sometimes puzzles me, why the compiler doesn't show me the line in my files instead of showing something in the standard libraries...
[/quote]

That's the same error. You still have a statement that is not terminated.

It should be fairly easy to track down since you just made changes that caused the headers to change. You know it is right before wherever you just included SDL.h.

A common place to forget the semicolon is at the end of a class definition. That might be where you forgot it, or it might be some other statement. For example: class Foo { ... }[b];[/b] // remember the semicolon.

Share this post


Link to post
Share on other sites
[quote name='PoriKori' timestamp='1306184275' post='4814746']
And I'm not that experienced in programming/C++ so it sometimes puzzles me, why the compiler doesn't show me the line in my files instead of showing something in the standard libraries...
[/quote]

Errors like this are to do with C++'s archaic module system, inherited from C. A #include statement is literally equivalent to just replacing the #include statement with the contents of the included file and is performed by the preprocessor, so the compiler only sees the code after this replacement has taken place. The fact that C++ is so notoriously hard to parse doesn't help either. (The reliability of VS2010's intellisense is quite remarkable bearing these things in mind).

As a result, the compiler is often missing the information required to tell you exactly what is causing the error. Try missing a semi-colon off the end of a class definition in a header then including it - chaos. Or messing up and missing a closing brace in a set of nested statements. Poor old compiler doesn't know what to think.

Stick with it and eventually you will get better at interpreting the likely cause of these errors.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this