CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: <fstream> problem with Borland Builder 6.0

  1. #1
    Join Date
    May 2007
    Posts
    4

    <fstream> problem with Borland Builder 6.0

    I am getting strange errors when I include <fstream> under BB 6.0.

    The following minimal program produces the error:

    ----------------------------------------------
    #include <fstream.h>

    void main ()
    {
    // read the propagation data
    int inDims;

    ifstream infile("C:\Documents and Settings\ChristianZ\My Documents\Software\vtk\examples\map scroll\infile.var");

    infile.read((char*) &inDims,4);
    }
    -------------------------------------------------

    BB 6.0 complains:

    [C++ Error] except.h(118): E2316'exception' is not a member of 'std'
    [C++ Error] except.h(118): E2303 Type name expected
    [C++ Error] _ios_base.h(48): E2303 Type name expected
    [C++ Error] iso.cpp(8): E2451 Undefined symbol 'ifstream'
    [C++ Error] iso.cpp(8): E2379 Statement missing ;
    [C++ Error] iso.cpp(8): E2451 Undefined symbol 'infile'

    Can anybody help me with this problem?

    Thanks,

    Christian

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: <fstream> problem with Borland Builder 6.0

    Isn't it "#include <fstream>" (no ".h")?

    Viggy

  3. #3
    Join Date
    May 2007
    Posts
    4

    Re: <fstream> problem with Borland Builder 6.0

    You are right, but I tried with and without ".h", the problem remains the same.

    -C

  4. #4
    Join Date
    Aug 2005
    Location
    The Matrix
    Posts
    159

    Re: <fstream> problem with Borland Builder 6.0

    Quote Originally Posted by zemlinc
    [C++ Error] except.h(118): E2316'exception' is not a member of 'std'
    [C++ Error] except.h(118): E2303 Type name expected
    [C++ Error] _ios_base.h(48): E2303 Type name expected
    [C++ Error] iso.cpp(8): E2451 Undefined symbol 'ifstream'
    [C++ Error] iso.cpp(8): E2379 Statement missing ;
    [C++ Error] iso.cpp(8): E2451 Undefined symbol 'infile'

    Can anybody help me with this problem?

    Thanks,

    Christian
    The error seems to be in except.h. Do you have these errors when you dont use #include<fstream> ?
    /** The only stupid question is the one you never ask. */

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: <fstream> problem with Borland Builder 6.0

    Quote Originally Posted by zemlinc
    You are right, but I tried with and without ".h", the problem remains the same.

    -C
    Did you remember to use namespace std? Also main() returns an int.

    It seems you are using material that is at least 10 years old. Usage of fstream.h has been deprecated, and the standard header is <fstream>. Get more modern C++ books and tutorials.

    Also, the title of the thread is misleading, since you originally did not use <fstream>, but <fstream.h>. They are not the same thing.
    Code:
    #include <fstream>
    
    int main()
    {
       std::ofstream ifs;
    }
    Does this compile? Note the std:: namespace.

    Last, this string contains illegal escape sequences:
    "C:\Documents and Settings\ChristianZ\My Documents\Software\vtk\examples\map scroll\infile.var")
    "\D", "\C", etc. are not legal escape sequences. Look at the third character in the string -- it is a "\D".

    The correct string is this:
    "C:/Documents and Settings/ChristianZ/My Documents/Software/vtk/examples/map scroll/infile.var")
    Forward slashes are used as directory separators for standard I/O functions.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 31st, 2007 at 09:24 PM.

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: <fstream> problem with Borland Builder 6.0

    If I recall correctly some of the early Borland headers had dependancies (which they should not). Figure out what you need to make the following compile:

    Code:
    #include <ThisIsWhatYouFigureOut>
    
    int main()
    {
       try
       {
           throw std::exception("Error");
       }
       catch (std::exception ex)
       {
       }
    }
    Once you have a valid header set for this, put those headers beofre the #include of <fsstream> in your original sample....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    Join Date
    Feb 2007
    Posts
    141

    Re: <fstream> problem with Borland Builder 6.0

    bro. CPUWIZARD can u tell me what is the advantage of using using namespace std::

  8. #8
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,116

    Re: <fstream> problem with Borland Builder 6.0

    Quote Originally Posted by nitin1979
    bro. CPUWIZARD can u tell me what is the advantage of using using namespace std::
    All of the STL (Standard Template Library) is in the std namespace. Writing modern C++ programs without using the STL, is just plain silly.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)