Author Topic: compiling errors?  (Read 3933 times)

Offline Svalorzen

  • Multiple posting newcomer
  • *
  • Posts: 11
compiling errors?
« on: April 03, 2009, 07:29:13 pm »
I've serched a bit in the forum for this, and i've not found anything. I'll post in the bug section if this happens to be one, but.. it kinda too stupid to be true.

Code
class Window {
    private:
        bool windowed;
        bool windowOK;
    public:
        Window();
        void handle_events();
        void toggle_fullscreen();
        bool error();
};

int main ( int argc, char * args [] ) {
    return 0;
}

with this code, i get 5 errors and 4 warnings.. wtf?

C:\Programmi\Tetris\Test.c|1|error: syntax error before "Window"|
C:\Programmi\Tetris\Test.c|1|error: syntax error before '{' token|
C:\Programmi\Tetris\Test.c|4|warning: type defaults to `int' in declaration of `windowOK'|
C:\Programmi\Tetris\Test.c|4|warning: data definition has no type or storage class|
C:\Programmi\Tetris\Test.c|5|error: syntax error before ':' token|
C:\Programmi\Tetris\Test.c|9|error: syntax error before "error"|
C:\Programmi\Tetris\Test.c|9|warning: type defaults to `int' in declaration of `error'|
C:\Programmi\Tetris\Test.c|9|warning: data definition has no type or storage class|
C:\Programmi\Tetris\Test.c|10|error: syntax error before '}' token|
||=== Build finished: 5 errors, 4 warnings ===|

even the declaration of the class ( class Window { ) has 2 errors. Also, sometimes i get errors with booleans variables, and i have to restart the compiler to be able to compile. Is this a known bug or have i to submit it?

Thanks for help ^_^

PS: this code is copied from a part of a SDL tutorial. If i compile the whole thing, it compiles. AND! If i cut all the other pieces in the tutorial and i leave it EXACTLY as the code above, it compiles. So, actually, i'm having 2 versions of the same code, one compiling, the other one not.
« Last Edit: April 03, 2009, 07:42:30 pm by Svalorzen »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: compiling errors?
« Reply #1 on: April 03, 2009, 07:44:37 pm »
I'll post in the bug section if this happens to be one, but..
Do you have your own bugtracker ?
Or do you seriously think about posting a bug in your code in our bug-tracker ?

I've serched a bit in the forum for this, and i've not found anything.
Maybe you should learn how to search.
If you search for "type defaults to `int' " and order by the most recent posts, the first one is yours and the second leads to the answer.


Why do so many people try to compile c++-code with a c-compiler ?

A file with a lower-case "c" as file-extension is treated as c-file at least on linux an uppercase "C" is treated as c++ in the most cases).

C does not know anything about classes, so you will not be able to compile it.

Change the file-extension to "cpp" and it will work (you might have to remove the file from project and readd it, to make it recognized as c++-file).

Offline Svalorzen

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: compiling errors?
« Reply #2 on: April 03, 2009, 08:10:04 pm »
As Bug Section i intended the site where the link in the post 'REPORT YOUR BUGS HERE' sends. ofcourse i've not my bugtracker, and the code is obviously not bugged.

btw, no needing to be rude. I haven't see the .c extension, simply because the evident text "Save as c/c++ file" in the Save window wasn't really leading me to suspect that code::blocks was going to save it as .c, hence causing the bugs.

So, probably ppl is not seeing this because when you save a file, and you select the format, the program says a thing but does another.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: compiling errors?
« Reply #3 on: April 03, 2009, 10:37:24 pm »
Thing is that reporting a bug just saying "my program does not compile, here is the compiler's error message" has nothing to do with us. We offer the IDE (we also have a nice bundle with a compiler), but we do not offer support for programming questions or compiler issues that have nothing to do with the IDE. Your problem is, however, somehow in the middle. It is a compiler issue, but it is also caused by the way the IDE calls it. Still, the IDE is right in calling the C compiler for a file with .c extension.

I know it is not nice to receive "rude" answers, but 1) it is also not nice to receive all the time questions that are completely off-topic (it is, not related to Code::Blocks), and 2) find the same question (or close enough) asked again. After a few months of it, that behavior can be expected.

Anyway, you got an answer for your problem and an explanation for the rudeness.