#721 ifstream.read() error

OTHER
closed
nobody
gcc (462)
works-for-me
User_Error
2013-01-31
2005-02-17
No

With gcc 3.3.1 and gcc 3.4.2 (both mingw) I get errors if:

if (storagebits == 32) {
for (i = 0; i < this->samples; i++ ) {
ifs.read(static_cast<char *>
(static_cast<void *>(&idata32)), sizeof( int));

ddata[i] = (double) (idata32 -
adc_dcoffset) * lsbval * adc_factor;
cout << i << " " << idata32 << " " <<
ddata[i] << " " << ifs.tellg() << endl;

after reading around 300 binary 32 bit values (casted
from char) I see that tellg() doe not increment with 4
bytes and the niumvbers I get are almost constant
(ddata[i]).

Ps.: The rouitine works fine since 3 years with linux
(Suse 7.2, 8.2, 9.2)

Discussion

  • Earnie Boyd

    Earnie Boyd - 2005-02-17
    • labels: 456608 --> gcc
    • assigned_to: earnie --> nobody
     
  • Danny Smith

    Danny Smith - 2005-02-17

    Logged In: YES
    user_id=11494

    Was ifstream opened in binary mode rather than default text
    mode? In text mode, CTRLZ (0x1A) means EOF.

    If this isn't the problem, please provide a self-contained test
    case so that the problem can be reproduced.

    Danny

     
  • Dr. Bernhard Friedrichs

    Logged In: YES
    user_id=348733

    Aha!
    It works fine now. So whyever linux does not care about the
    binary flag and also cygwin was working, mingw seems to be
    more precise.
    Thank you very much for your helpful comment.
    Regards, Bernhard

     
  • Danny Smith

    Danny Smith - 2005-02-18
    • status: open --> closed-works-for-me
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-31
    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> User_Error
    • milestone: Known_bugs --> OTHER
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks