title: Is it possible to allocate different memory location for structure members in C?
body: <p>For the following structure object</p>
  
  <pre><code>struct test
  { 
  int a;       //expect address location 0xabcd
  int b;       //expect address location 0xmnop
  } test1;
  </code></pre>
  
  <p>The expectation is to have different memory locations assigned for variable a and variable b for test1 instance.</p>
  
  <p>I understand that such a thing is possible for global variables by using 
   #pragma address </p>
  
  <p><strong>Questions 1:</strong> Can this also be extended to structures too.</p>
  
  <p>if Not then, </p>
  
  <p><strong>Question 2:</strong> What is a better way to do this?</p>
  
  <p><strong>The constraints are:</strong></p>
  
  <ol>
  <li>Both variables must stay together logically.</li>
  <li>The physical addresses must be separate(configurable somehow).</li>
  </ol>
  
  <p><strong>Edit 1:</strong>
  To clarify further, The above structure contains variables that indicate the locations in a certain buffer. (closest analogy will be the Read/Write indexes in a queue) 
  Here, however, each variable must be stored in a separate location to be protected from accidental access by some modules.</p>