Author Topic: CB Compile Errors [Detailed Error Description]  (Read 4903 times)

Offline KrazENooB

  • Single posting newcomer
  • *
  • Posts: 2
CB Compile Errors [Detailed Error Description]
« on: August 07, 2013, 07:17:07 am »
Okay, so been having this issue come and got for at least a week now. I have tried all I can to figure out where my compiler/codeblocks is breaking, and to no avail.

I am running Windows 7 64 bit with all the latest updates, I am running the latest CB with the minGW bundle, and I have already tried uninstalling and re-installing the program, it works... once, maybe twice... Then breaks, this time it popped up with a Copyright Warning.. For the C++ Standard Library???

I am morbidly confused...

So, let's take it from the top gents, and get to the bottom of what I am sure the 100+ Newbie coders who visit this forum are having trouble with. Because there is NO way this has been solved yet, (less my google/search skills be void.)

So, Fresh CB install from here.... codeblocks-12.11mingw-setup_user.exe

Now to install... Done..

Okay, FRESH FULL install at the ABSOLUTE default values. Not a thing changed? Let's run Hello World!

Code
// my first program in C++

#include <iostream>
using namespace std;

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

AND THE RESULT...

Code
C:\Users\Jay\Documents\CODE STUFF\Newb Stuff\Test\Untitled1.c|1|error: expected identifier or '(' before '/' token|
C:\Users\Jay\Documents\CODE STUFF\Newb Stuff\Test\Untitled1.c|3|fatal error: iostream: No such file or directory|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 8 seconds) ===|

I don't understand how a FRESH install, could result in such errors? What am I doing wrong here... Hmm, Perhaps my compilers not set up right? Oh.. but I just installed it? Well, just a gander anyways...

[img=http://s13.postimg.org/96jjn21qb/Untitled.jpg]

This is the basic Compiler, showing my toolchain settings...

I don't get it, I am no Davinci, but honestly this seems to make no sense...

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
Re: CB Compile Errors [Detailed Error Description]
« Reply #1 on: August 07, 2013, 07:43:18 am »
This looks like a general programming issue and not one related to codeblocks. If you want the program to compile as a C++ program, the easiest thing to do is to rename your files to have a .cpp extension instead of .c. The compiler sees .c and assumes a C program, but if it sees a .cpp extension, it assumes C++. I think there is a checkbox in the compiler settings to force C++, but just renaming the file is the better thing to do. It also indicates to others who look at the code/files what language you are targeting.

Offline KrazENooB

  • Single posting newcomer
  • *
  • Posts: 2
Re: CB Compile Errors [Detailed Error Description]
« Reply #2 on: August 08, 2013, 02:22:12 am »
Thank you, that cleared it up. No wonder all the fancy solutions where not helping.