User forums > Help

CB Compile Errors [Detailed Error Description]

(1/1)

KrazENooB:
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;
}
--- End code ---

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) ===|

--- End code ---

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...

sorinev:
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.

KrazENooB:
Thank you, that cleared it up. No wonder all the fancy solutions where not helping.

Navigation

[0] Message Index

Go to full version