News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

How to make headers work?

Started by Adestro, May 08, 2008, 10:36:07 AM

Previous topic - Next topic

Adestro

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.

#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!

stahta01

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
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Adestro


JGM

Quote from: stahta01 on May 08, 2008, 02:01:15 PM
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.