title: Why does my JNA Structure mapping produce strange field values?
body: <p>I am trying to call functions from a dll generated by Mathlab. It appears to work ok in C, but it returns weird results when i try to use jna. </p>
  
  <p>I am trying to call the function with the following signature : </p>
  
  <pre><code>emxArray_real32_T *emxCreate_real32_T(int rows, int cols);
  </code></pre>
  
  <p>with the structure: </p>
  
  <pre><code>struct emxArray_real32_T
  {
      float *data;
      int *size;
      int allocatedSize;
      int numDimensions;
      boolean_T canFreeData;
  };
  </code></pre>
  
  <p>The structure is mapped in java to: </p>
  
  <pre><code>public interface LibSoftEdge extends StdCallLibrary {
          public static class emxArray_real32_T extends Structure{
  
  
              public Pointer data ;
              public Pointer size;
              public int numDimensions;
              public int allocatedSize;
              public boolean canFreeData;
  
              @Override
              protected List getFieldOrder() {
                  return Arrays.asList(new String[]{"allocatedSize","canFreeData",
  
  "data","numDimensions","size"});
              }
  
  
              @Override
              public String toString() {
                  return "emxArray_real32_T{" +
                          "data=" + data +
                          ", size=" + size +
                          ", allocatedSize=" + allocatedSize +
                          ", numDimensions=" + numDimensions +
                          ", canFreeData=" + canFreeData +
                          '}';
              }
          }
  
          emxArray_real32_T emxCreate_real32_T(int rows, int cols);
      }
  </code></pre>
  
  <p>and i call it with : </p>
  
  <pre><code>LibSoftEdge libM = (LibSoftEdge) Native.loadLibrary("libsoftedge", LibSoftEdge.class);
  LibSoftEdge.emxArray_real32_T  test; 
  test =     libM.emxCreate_real32_T(3,3);
  </code></pre>
  
  <p>In the test object I get weird values and null pointers. </p>
  
  <p>Any suggestion is much apreciated.</p>