title: Passing swift struct pointer to C function
body: <p>Let's say, I have Swift struct named Foo</p>
  <pre><code>struct Foo
  {
       var a,b,c : Float
       var d : Double
       init()
       {
          a = 0
          b = 0
          c = 0
          d = 0
       }
  }
  </code></pre>
  <p>Swift sizeof(Foo) prints 24 bytes, 4 bytes for Float fields, 8 for Double and 4 bytes of padding on arm64.</p>
  <p>So I consider, that there is no special Swift magic with structures alignment done, and we can freely pass pointers to it to internal C functions in order to use stuff like NEON and Metal, as long as built-in variables are unions, which currently can't be directly included into Swift</p>
  <p>Somehow, when I try to get const void* to it (ConstUnsafePointer&lt;()&gt; in Swift) with</p>
  <pre><code>let a = Foo()
  let b = &amp;a
  </code></pre>
  <p>I get nasty compiler error on second expression</p>
  <pre><code>'Foo' is not convertible to '@lvalue inout $T1'
  </code></pre>
  <p>Did I miss something and this is done by design?</p>
  <h1>UPDATED PART</h1>
  <p>Martn R, thanks for answer! Still, entire situation is not very clear for me. My aim was to create convenient Math stuff wrapper, so I wanted to implement @infix methods like multiplication and hide all internal native stuff behind C. In case of Matrices, for example, that means, that we need to pull ampersand right from a = &amp;b*&amp;c expressions, because I didn't get from your answer and Docs if there is a way to bypass this and get raw point from memory in the scope of @infix method implementation.</p>
  <p>Like this:</p>
  <pre><code>@infix public func *(l: Mat4, r: Mat4) -&gt; Mat4
  {
      var m = Mat4()
      _internalMat4Multiply(&amp;l, &amp;r, &amp;m)
  }
  </code></pre>
  <p>_internalMat4Multiply is void(void*, void*, void*) C-method, doing all the computations</p>