Qbasicnews.com

Full Version: Dev C++ 5 compiling
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I downloaded the latest release from bloodshed the other day and am having a few problems.

As project I was working on in the final version of devc++4 and allegro now has some compile issues.
the includes like <fstream.h> and <iostream.h> are bringing up warnings to effect of theyre no longer supported and i must use the new includes. the project compiles (these are just warnings) but crashes. I think its when its doing the file io.

What are these new includes and can i maybe get a list of them or something??
I've had trouble too...it's the version of gcc. I'd use the cygwin or a devc++ 4's compiler.
According to the new standard:

Code:
#include <iostream>
And then:

Code:
using namespace std;

or instead of using "using namespace std;" you could add "std::" to all components of iostream, like:

Code:
std::cin >> var;
I was just messing around and noticed in the include directory none of the files ha .h appended. so i included the file as <fstream> (thanks HQS) witch has stoped that compile error, but..

now i get an error at the ifstream.
Code:
ifstream myFile("path/blah/file.ext");
again, this is code that compiled perfectly with the mingw compiler that was with dev4.
will that using namespace thing stop that (cant test it yet, different computer)?
if so, why?
Oh, right. i get it.

Okay Dev-c++ 4, depending on what version you use, has broken namepace support in it's gcc version, im guessing you didnt simply update just Dev-c++ , you updated the compiler as well?(dev-c++ 5 now ships with gcc 3.1.0 as opposed to the 2.x version 4 ships with).

So yeah, use namepaces. I just wanted to explain WHY the compiler is complaining.
This is because Dev C++ 5 uses the new standard. Instead of:

Code:
using namespace std;

You should use "std::" because then it doesn't load all iostream's components, which is better for the use of memory.

As for the ifstream prob, I don't know. Can I see your entire code? If it's really huge, just PM it
Hmm... I've had some compiling issues too with devc++.
Errors pointing to various header files, and I know the code's ok,
it compiles on another system...

So you're saying that if i remove "using namespace std;"
and put std:: before all cin's and cout's it will work?

I'll have to check tomorrow Yaaawn...
ok, putting using namespace std got the project to compile without the compiler screaming at me, but...

my prog still crashes when it does the ifstream.
Code:
using namespace std;
ifstream myFile("thepath/blah.ext");
why is it doing this?

EDIT: ill post the code later, its not on this computer, but im pretty sure that the problem is with the ifstream.
with my level editor, it works fine until i try load a map, it crashes.
i havnt tried saving a map come to think of it...
ill try that and get back to you guys
Quote:So you're saying that if i remove "using namespace std;"
and put std:: before all cin's and cout's it will work?
Yes also if you put a bunch of classes in your own namespace, eg mynamespace you can type using namespace my namspace; or just add mynamespace::functionname();
heres the function thats crashing the program
Code:
void loadMap(int into[][200], char *from, int maxX, int maxY) {
    std::ifstream lod(from);
        for (int y=0; y<=maxY; y++) {
            for (int x=0; x<=maxX; x++) {
                lod>>into[x][y];
            }
        }
    lod.close();
}

loadMap(map, "data/map.map", 200, 200);
this compiled and ran fine with dev4. whats even more strange is with the level editor, im using a similar version of this function (hard coded what array is going into and the path etc.), and it works fine.
in other words, ifstream works fine with the level ed, but seems to crash my game code.
this is beginning to bug me Sad
Pages: 1 2