Author Topic: How to make headers work?  (Read 4111 times)

Adestro

  • Guest
How to make headers work?
« 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: [Select]
#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!

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7065
    • My Best Post
Re: How to make headers work?
« Reply #1 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
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Adestro

  • Guest
Re: How to make headers work?
« Reply #2 on: May 08, 2008, 10:10:07 pm »
Thanks a lot! Worked! :)

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: How to make headers work?
« Reply #3 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.