title: warning C4316: object allocated on the heap may not be aligned 16
body: <p><strong>Important Information:</strong></p>
  
  <ul>
  <li>Development OS: Windows 8.1 64 bit</li>
  <li>Target OS: Windows 8.1 64 bit</li>
  <li>IDE: Visual Studio 2013 Professional</li>
  <li>Language: C++</li>
  </ul>
  
  <p><strong>The Problem:</strong></p>
  
  <p>I get the following warning when compiling my static library project through the IDE:</p>
  
  <pre><code>warning C4316: ... : object allocated on the heap may not be aligned 16
  </code></pre>
  
  <p>I could simply ignore this warning...but I'm assuming it's there for a reason and would like to at least understand what it means and what implications it could have in the future.</p>
  
  <p><strong>I believe this line of code is related to the problem</strong>, which is called inside my Win32 window wrapper class:</p>
  
  <pre><code>m_direct3D = new Direct3D(this);
  </code></pre>
  
  <p>m_direct3D is a pointer to my Direct3D wrapper class.</p>
  
  <p><strong>Here is the header file for the wrapper</strong> (I admit it needs trimming down):</p>
  
  <pre><code>#pragma once
  
  // Windows
  #include &lt;d3d11.h&gt;
  #include &lt;DirectXMath.h&gt;
  
  // Standard
  #include &lt;stdint.h&gt;
  #include &lt;vector&gt;
  
  // JGlib
  #include "Window.h"
  
  namespace JGlib
  {
      namespace Graphics
      {
          class Direct3D
          {
          public:
              // Construtor and destructor
              Direct3D(const JGlib::Graphics::Window* window);
              ~Direct3D();
  
              // Public methods
              void Initialise();
              void BeginDraw();
              void Draw();
              void EndDraw();
  
          private:
              // Private methods
  
              // Private member variables
              const Window*               m_window;
              ID3D11Device*               m_device;
              IDXGIAdapter*               m_adapter;
              DXGI_ADAPTER_DESC           m_adapterDescription;
              uint32_t                    m_videoCardMemory;
              IDXGIFactory*               m_factory;
              IDXGIOutput*                m_monitor;
              DXGI_MODE_DESC*             m_displayModes;
              uint32_t                    m_numberOfModes;    
              DXGI_RATIONAL               m_refreshRate;
              DXGI_SWAP_CHAIN_DESC        m_swapChainDescription;
              D3D_FEATURE_LEVEL           m_featureLevel;
              ID3D11DeviceContext*        m_deviceContext;
              IDXGISwapChain*             m_swapChain;
              ID3D11Texture2D*            m_backBuffer;
              ID3D11RenderTargetView*     m_renderTargetView;
              ID3D11Texture2D*            m_depthStencilBuffer;
              D3D11_TEXTURE2D_DESC        m_depthBufferDescription;
              D3D11_DEPTH_STENCIL_DESC    m_depthStencilDescription;
              ID3D11DepthStencilState*    m_depthStencilState;
              ID3D11DepthStencilView*     m_depthStencilView;
              D3D11_RASTERIZER_DESC       m_rasterDescription;
              D3D11_VIEWPORT              m_viewport; 
              float                       m_fieldOfView;
              float                       m_screenAspectRatio;
              ID3D11RasterizerState*      m_rasterState;
              DirectX::XMMATRIX           m_projectionMatrix;
              DirectX::XMMATRIX           m_worldMatrix;
              DirectX::XMMATRIX           m_orthographicMatrix;
              float                       m_screenDepth;
              float                       m_screenNear;
          };
      }
  }
  </code></pre>
  
  <p>I tried googling the issue, but found little information. The information I did find I did not understand.</p>
  
  <p><strong>The conclude, I am asking the following:</strong></p>
  
  <ol>
  <li>What does C4316 mean?</li>
  <li>What is causing it in my code?</li>
  <li>What implications could this have in the future, if I ignore it?</li>
  <li>How do I "fix" the problem that is causing this warning to appear?</li>
  </ol>
  
  <p><strong>Additional Information:</strong></p>
  
  <p>When I changed Visual Studio's configuration manager to compile for x64, this issue does not occur.</p>