Re: fstream on Irix - SGI

This is a discussion on Re: fstream on Irix - SGI ; * Mark Hellegers | According to the man page for fstream, there should be some | functions to do this. If I read it correctly there should be an | attach function and the constructor to do this, but this ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: fstream on Irix

  1. Re: fstream on Irix

    * Mark Hellegers
    | According to the man page for fstream, there should be some
    | functions to do this. If I read it correctly there should be an
    | attach function and the constructor to do this, but this doesn't
    | work. The compiler says they don't exist and the fstream header
    | indeed does not have these functions.

    IIUC iostream::attach is no longer in the C++ Standard.
    This works for me w/o attach:

    int fd = open("foo", O_RDONLY);
    if (fd < 0) {
    perror("open");
    } else {
    ifstream fstr(fd);

    // demo only, caveat buffer overflows!
    char buffer[1024];
    fstr >> buffer;
    printf("buffer '%s'\n", buffer);
    }

    R'

  2. Re: fstream on Irix

    In message , Ralf Fassel wrote:
    > * Mark Hellegers
    > | According to the man page for fstream, there should be some
    > | functions to do this. If I read it correctly there should be an
    > | attach function and the constructor to do this, but this doesn't
    > | work. The compiler says they don't exist and the fstream header
    > | indeed does not have these functions.
    >
    > IIUC iostream::attach is no longer in the C++ Standard.
    > This works for me w/o attach:
    >
    > int fd = open("foo", O_RDONLY);
    > if (fd < 0) {
    > perror("open");
    > } else {
    > ifstream fstr(fd);
    >
    > // demo only, caveat buffer overflows!
    > char buffer[1024];
    > fstr >> buffer;
    > printf("buffer '%s'\n", buffer);
    > }


    Hmm, this isn't working here. What compiler are you using ?
    I should have mentioned this in the initial post, but I'm using the MipsPro 7.3
    compiler.

    I'm getting this error message:

    cc-1262 CC: ERROR File = BinaryFile.cpp, Line = 26
    No instance of constructor
    "std::basic_ifstream>::basic_ifstream"
    matches the argument list.

    The argument types are: (int).
    ifstream object( fd );


    Mark


+ Reply to Thread