[OpenWalnut-Dev] Write file reader for WDataSetScalar

Mario Hlawitschka dh1pa at amsat.org
Fri May 11 09:08:27 CEST 2012


Hi Frank,

how do you check that tmp has the right value?
The reinterpret_cast here seems not to be what you want it to be. It will store the data as if the memory was a char, but then you reinterpret the values as an int. At least on a machine with a different endianess, this will cause problems that should be avoided.

Please try using:
char tmp;
m_ifs->read( &tmp,  1); // Read 1 byte.
(*myData)[i] = (int)tmp;

Is there any reason you want to store the data in ints if the file only contains single-byte data?

	Mario

On May 10, 2012, at 5:58 PM, Frank Zisko wrote:

> m_ifs->read( reinterpret_cast<char*>(&tmp),  1); // Read 1 byte.
>        (*myData)[i] = tmp;



More information about the OpenWalnut-Dev mailing list