Errors in stdio.h?!

Started by
7 comments, last by Aardvajk 12 years, 11 months ago
(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.
Advertisement
The first error you have is "expected ',' or ';' before extern".

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.
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.
Uint32 is a typedef declared in SDL.h, so you have to include that to use it.

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.


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.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)


Uint32 is a typedef declared in SDL.h, so you have to include that to use it.

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!

[quote name='Narishma' timestamp='1306183666' post='4814739']
Uint32 is a typedef declared in SDL.h, so you have to include that to use it.

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 { ... }; // remember the semicolon.
Actually it was a pretty silly spot. I forgot it after declaring one of the constants :/

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


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.

This topic is closed to new replies.

Advertisement