Note that there are some explanatory texts on larger screens.

plurals
  1. POVector won't store correct datatype (wchar_t instead of uint16_t)
    primarykey
    data
    text
    <p>I have some code from the net reading hyperspectral data (image, so lots of integers giving pixel intensity) into a vector. I used the code with success on a Linux system, but now I need the same on a windows system. I use Visual Studio 2008.</p> <p>Reading the data in Linux I get a vector full of integers. On windows I get the integers and then some chars or byte data. I don't know enough to describe it better.</p> <p>The vector is initialized by</p> <pre><code>std::vector&lt; unsigned short int &gt; data; data.resize( samples * lines * bands ); std::fill( data.begin(), data.end(), 0 ); </code></pre> <p>and the relevant code is</p> <pre><code>for( unsigned int i=0; i &lt; num_pixels &amp;&amp; file; ++i ){ char number[sizeof(DataType)]; file.read( number , sizeof( DataType ) ); int l = sizeof(DataType)-1; if (machine_endian != header.big_endian) { for (int j = 0; j &lt; l; j++, l--){ number[j] ^=number[l]; number[l] ^= number[j]; number[j] ^= number[l]; } } unsigned short temp = *((unsigned short int*)number); data[i] = temp; } </code></pre> <p>The machine_endian part is never run. The temp is just to test if I can cast the number into an int. It works fine. However, when I put temp into the vector there's more information inserted than just the int and it's listed as wchar_t. See the image below. I guess it's something to do with type size, but I am clueless as to why. Is it mine or Visual Studios fault? Any ideas?</p> <p><a href="https://i.stack.imgur.com/0pFQP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0pFQP.png" alt=""></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload