title: Renaming fields of struct imported from dll
body: <p>I'm building a framework for a series of compiled Simulink models (they are code generated into C DLLs). In each of the dlls there are entry points that you can use to access the input and output of the simulations, and they can for instance look like this (from the dll´s header file):</p>
  
  <pre><code>typedef struct {
    Ms_MainBus Ms_MainBus_a;
  } ExternalOutputs_vcts_electrical;
  </code></pre>
  
  <p>However, eventhough all of the models have the same I/O data structure (Ms_MainBus), the actual variable names change, so for instance in another dll the signal might be called <code>Ms_MainBus_b</code> instead of <code>Ms_MainBus_a</code>. This is extremely annoying, as I try to build a generic framework that can handle a large number of these models, and shouldn't require knowledge of what letter Matlab has appended to the signal name.</p>
  
  <p>To solve this, I tried the following:</p>
  
  <p>Defined a struct that has the signal name I want every model to use</p>
  
  <pre><code>typedef struct {
     Ms_MainBus MainBus;
  } stdInput;
  </code></pre>
  
  <p>I then proceed to import the input and output variables from the dll into a class called Ele.</p>
  
  <p>In Ele.h, I first try to override the input structure from the header file</p>
  
  <pre><code>#undef ExternalOutputs_vcts_electrical
  #define ExternalOutputs_vcts_electrical stdOutput
  </code></pre>
  
  <p>And then declare the input variable</p>
  
  <pre><code>ExternalOutputs_vcts_electrical (*output);
  </code></pre>
  
  <p>And in Ele.cpp</p>
  
  <pre><code>this-&gt;output = (ExternalOutputs_vcts_electrical*)GetProcAddress(this-&gt;lib, "vcts_electrical_Y");
  </code></pre>
  
  <p>It works, and I can access <code>output.MainBus</code>, but if I try to change the value of the input to the model, nothing happens. It's like the dll uses another workspace than my code. I haven't had that problem before I started with this renaming business, so I'm guessing the problem is in the <code>#undef, #define</code> part, correct?</p>
  
  <p>How should I do?</p>