Welcome to GameHourz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

PDcurses incompatibility with fstream.h?

 
   Game Forums (Home) -> Roguelike -> Development RSS
Next:  windows gaming  
Author Message
kobuscrispi

External


Since: Mar 26, 2006
Posts: 9



(Msg. 1) Posted: Tue Apr 04, 2006 3:31 pm
Post subject: PDcurses incompatibility with fstream.h?
Archived from groups: rec>games>roguelike>development (more info?)

Okay, this is probably more reflective of my lack of understanding of
C++ than anything else, but here goes.

I'm writing a roguelike, I've gotten it to the point where the player
can move around, look, and open/close doors, and I was gearing towards
moving the map data to an external file when I ran into some problems.
I wanted to use fstream.h for the file input/output. However, as soon
as I include it, I get *72* errors! Further investigation revealed that
most, if not all, of these errors were caused by the fact that curses.h
and fstream.h both try to define a function called clear(). Is there
any way to get these two files to coexist peacefully? Probably
something obvious I've overlooked?

Thanks in advance.

 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
Jim Strathmeyer

External


Since: Nov 27, 2005
Posts: 38



(Msg. 2) Posted: Tue Apr 04, 2006 7:58 pm
Post subject: Re: PDcurses incompatibility with fstream.h? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

kobuscrispi.RemoveThis@gmail.com schrieb:
> Okay, this is probably more reflective of my lack of understanding of
> C++ than anything else, but here goes.

Isn't fstream's clear in the std namespace? I'm not sure.

Also, although it doesn't concern me that you mistakenly used fstream.h
instead of just fstream, but it does concern me that your compiler
didn't tell you to.

--
Jim Strathmeyer

 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
Adam White

External


Since: Apr 05, 2006
Posts: 13



(Msg. 3) Posted: Tue Apr 04, 2006 8:55 pm
Post subject: Re: PDcurses incompatibility with fstream.h? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 04 Apr 2006 15:31:20 -0700, kobuscrispi wrote:

[snip]

> I wanted to use fstream.h for the file input/output. However, as soon
> as I include it, I get *72* errors! Further investigation revealed that
> most, if not all, of these errors were caused by the fact that curses.h
> and fstream.h both try to define a function called clear(). Is there
> any way to get these two files to coexist peacefully?

The problem probably isn't exactly caused by the function clear(), it's
likely caused by the macro of the same name. The easiest way to fix it is
to

#undef clear

after including [n]curses.h.

For convenience, a lot of the functions dealing with stdscr in curses.h
are macros to the actual [mv]w{foo} functions.

<fstream.h> is an old c++ header though - you might be better off moving
to the new <fstream> style.

Cheers,
Adam
 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
kobuscrispi

External


Since: Mar 26, 2006
Posts: 9



(Msg. 4) Posted: Tue Apr 04, 2006 10:03 pm
Post subject: Re: PDcurses incompatibility with fstream.h? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

To be honest, I wasn't even aware that there was any functional
difference between <fstream.h> and <fstream>. But now I know!

How are they different, exactly?
 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
Jim Strathmeyer

External


Since: Nov 27, 2005
Posts: 38



(Msg. 5) Posted: Wed Apr 05, 2006 11:02 am
Post subject: Re: PDcurses incompatibility with fstream.h? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

kobuscrispi DeleteThis @gmail.com schrieb:
> How are they different, exactly?

Just that the .h includes are deprecated, I think for all the standard
headers. There's no real way you would know unless someone told you.
There should be no functional difference, though, except if you
distributed your code my compiler would force me to change it manually.

--
Jim Strathmeyer
 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
Adam White

External


Since: Apr 05, 2006
Posts: 13



(Msg. 6) Posted: Wed Apr 05, 2006 11:55 pm
Post subject: Re: PDcurses incompatibility with fstream.h? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 05 Apr 2006 11:02:37 -0500, Jim Strathmeyer wrote:

[ <fstream> vs <fstream.h> ]

> kobuscrispi.TakeThisOut@gmail.com schrieb:
>> How are they different, exactly?
>
> Just that the .h includes are deprecated, I think for all the standard
> headers. There's no real way you would know unless someone told you.

Well, that's true for the c-style headers. So for <string.h> for example,
the only difference between <cstring> and <string.h> is that all entities
in <cstring> are only in the std:: namespace, whereas they're in both
the std:: and the global namespaces for <string.h>.

Of course there are exceptions, such as the "float abs(float, float)"
overload in <cstdlib> which doesn't appear in <stdlib.h>.

> There should be no functional difference, though, except if you
> distributed your code my compiler would force me to change it manually.

For <fstream> though, and this is true of almost the entire <iostream>
hierarchy, there are differences. Older versions used strstreams
(often shortened to <strstrea.h>), which were char * based rather than
modern stringstreams.

Moral: You're using the modern library and getting better support if you
use the modern style rather than relying on the deprecated headers and
library support.

Cheers,
Adam
 >> Stay informed about: PDcurses incompatibility with fstream.h? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Problems with PDcurses - I'd like to preface this by saying that I am VERY new to the roguelike development scene, so I'm trying to learn most of this as I go. I just picked up a copy of PDcurses, and I've been experimenting with it. addch() , addstr() and getch() seem to be..

init_color() in PDCurses - OK, along with the X11 and DOS ports, the Win32 port of PDCurses now has a working init_color() and color_content(). You can try it out now via anonymous CVS; otherwise you'll have to wait for the next release. Limitations in the Win32 port: 1) Works..

Colors in pdcurses vs. ncurses - Hi, I've noticed that the default color macros in pdcurses (BGR) are not the same as the default in ncurses (RGB): ncurses: COLOR_BLACK = 0 COLOR_RED COLOR_GREEN COLOR_YELLOW COLOR_BLUE COLOR_MAGENTA COLOR_CYAN COLOR_WHITE = 7 pdcurses: #define..

7DRL: Invader - Well, I've talked myself into attempting a game for the 7DRL challenge. :-) Invader will be a sci-fi RL where the player is the planet's only hope of stopping a dread alien invasion ship. The character's base of operations will be their docked ship. ....

7DRL: TBA! :P - I'm going to throw my hat into the 7drl arena by taking on a project I've wanted to do for ages. I think it will get me past the mental block of actually getting started. My concept is based around the remains of a post apocalyptic world with gang..
   Game Forums (Home) -> Roguelike -> Development All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]