Code::Blocks Forums

User forums => Help => Topic started by: Adestro on May 08, 2008, 10:36:07 am

Title: How to make headers work?
Post by: Adestro on May 08, 2008, 10:36:07 am
I installed the codeblocks-8.02mingw-setup and created a project and fired up a hello world application. But the compiler can't find the core c++ headers.

Code
#include <iostream>
using namespace std;

int main ()
{
    cout << "Hello World!";
    return 0;
}

-------------- Build: Debug in Test ---------------

Compiling: main.c
F:\...\Test\main.c:3:20: iostream: No such file or directory
F:\...\Test\main.c:4: error: syntax error before "namespace"
F:\...\Test\main.c:4: warning: type defaults to `int' in declaration of `std'
F:\...\Test\main.c:4: warning: data definition has no type or storage class
F:\...\Test\main.c: In function `main':
F:\...\Test\main.c:8: error: `cout' undeclared (first use in this function)
F:\...\Test\main.c:8: error: (Each undeclared identifier is reported only once
F:\...\Test\main.c:8: error: for each function it appears in.)
Process terminated with status 1 (0 minutes, 0 seconds)
5 errors, 2 warnings

Please help me!
Title: Re: How to make headers work?
Post by: stahta01 on May 08, 2008, 02:01:15 pm
Try using an filename of main.cpp instead of main.c.
C::B thinks that if the file ends with .c you are doing C programming.

Tim S
Title: Re: How to make headers work?
Post by: Adestro on May 08, 2008, 10:10:07 pm
Thanks a lot! Worked! :)
Title: Re: How to make headers work?
Post by: JGM on May 09, 2008, 06:15:57 am
C::B thinks that if the file ends with .c you are doing C programming.

I thought gcc was the one thinking that of *.c files.