Jump to content
  • Advertisement
Sign in to follow this  
Rasmadrak

[ "SOLVED" ] fstream or FILE won't work inside debugger?

This topic is 3994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I'm having troubles using the Code::Blocks compiler, such as fstream or FILE won't work while debugging - the only response I get is that the variable is an "incomplete type". However, if I launch the application externaly, it works fine. This is as you can imagine quite annoying and it also makes it impossible to debug the file input functions... Btw, I've tried running the exact same functions in another compiler and they work fine.. problem is that I'd rather avoid that compiler at all costs. :) Does anyone have a remedy for this? Or an alternative method of getting input from files? Thanks for your time! /Robert [Edited by - Rasmadrak on July 17, 2007 6:40:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Rasmadrak
Hi!

I'm having troubles using the Code::Blocks compiler, such as fstream or FILE won't work while debugging - the only response I get is that the variable is an "incomplete type". However, if I launch the application externaly, it works fine.


That sounds like a compiler error. Are you sure the application you're launching is the one you just finished writing (i.e. that you compiled it successfully and it's in the place you expect)?

Share this post


Link to post
Share on other sites
Yepp, it's the same application. :)

Using fstream:
One thing I've noted however is that although the file I try to load is found when I launch the application externaly, the values returned are garbled unless I try to get some text!

Using FILE:
It all works correctly if not launched by compiler.

Is it possible that the fstream and FILE headers are corrupted in any way? Are they part of the Windows API or C++..?

Share this post


Link to post
Share on other sites
Rather than a compiler error, it probably is that the IDE is unable to visualise structured types like FILE is. That is, taken from Wikipedia FILE is

# FILE - a structure containing the information about a file or text stream needed to perform input or output operations on it, including:

* the current stream position
* an end-of-file indicator
* an error indicator
* a pointer to the stream's buffer, if applicable
.

I'm not familiar with Code::Blocks compiler, but perhaps you should check the possibility of displaying custom data types. With a quick search I couldn't find anything related to your spesific IDE, but in Visua Studio it is done like this (note the small print regarding native code). Even with different systems, the principles are usually the same.

Hope this helps.

[EDIT: corrected a minor spelling error and changed compiler to IDE as that was the thing I meant.]

Share this post


Link to post
Share on other sites
I'm going to point out the obvious just in case. Have you downloaded the latest version of Code::Blocks? Last I checked, the one on their download page is dated, so use their SVN version, which is update very frequently.

Share this post


Link to post
Share on other sites
Yes, the one I downloaded is the recommended "nightly" build... this was a little more than a week ago so it shouldn't be dated.
it really sounds like some debugger/compiler problem... Maybe I'll try install MinGW later today.

Thanks for your input thou! :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Naurava kulkuri
...I'm not familiar with Code::Blocks compiler, but perhaps you should check the possibility of displaying custom data types....


I realized that I was using the terms rather loosly, since I get the same behaviour if I try to compile&run the application from the IDE regardless if I'm debugging or not. So it's probably not an issue with the debugger but rather the IDE itself.

back to the drawingboard again... :)

Share this post


Link to post
Share on other sites
I managed to solve this using the library "fstream", but it seems as if I have to provide an absolute path to the file I want to load, i.e "c:/project/file.txt" instead of just "file.txt".

Does anyone know a remedy to this? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Rasmadrak
I managed to solve this using the library "fstream", but it seems as if I have to provide an absolute path to the file I want to load, i.e "c:/project/file.txt" instead of just "file.txt".

Does anyone know a remedy to this? :)


Your problem seems to be that your program runs in some other directory than the application directory during debug. There might be some option of settings the working directory of the executable while debugging. Sniff around in the project options.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!