On 08/09/2011 06:34 PM, Amos Jeffries wrote:
> On Tue, 09 Aug 2011 12:56:09 -0600, Alex Rousskov wrote:
>> On 08/09/2011 02:13 AM, Kinkie wrote:
>>>> ./cf_gen cf.data ../../src/cf.data.depend
>>>> error while opening input file 'cf.data': Unknown error: 0
>>>
>>> Now this puzzles me.
>>> ifstream fp.bad() reports badbits set, but errno is OK. On FreeBSD
>>> 6.4 only.
>>
>> Perhaps the errno is reset by subsequent system calls? How close is your
>> bad() detection to the errno use?
>>
> 
> The code in question is:
> 
>     fp.open(type_depend, std::ifstream::in);
>     if (fp.fail()) {
>         std::cerr << "error while opening type dependencies file '" <<
>                   input_filename << "': " << strerror(errno) << std::endl;
>         exit(1);
>     }
Does rewriting the above to preserve errno (as in the sketch below) help?
    fp.open(...);
    if (!fp) {
        const int savedErrno = errno;
        std::cerr << "error: " << strerror(errno) << std::endl;
    }
Cheers,
Alex.
Received on Wed Aug 10 2011 - 14:11:17 MDT
This archive was generated by hypermail 2.2.0 : Wed Aug 10 2011 - 12:00:03 MDT