title: Error in C++ code linkage: warning C4190: type has C-linkage specified, but returns UDT which is incompatible with C
body: <p>I am having a hard time understanding why the following code (UDT with standard layout) gives a C-linkage warning in visual C++ 2012: </p>
  
  <pre><code>warning C4190: 'vec3_add' has C-linkage specified, but returns UDT 'vec3' which is incompatible with C
  
  
  
  typedef struct vec3 {
      float   x;
      float   y;
      float   z;
  #ifdef __cplusplus
      vec3(float x, float y, float z) : x(x), y(y), z(z) {}
  #endif
  } vec3;
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  vec3    vec3_add(vec3 a, vec3 b);
  #ifdef __cplusplus
  }
  </code></pre>
  
  <p>The definition of the function is in a C++ file:</p>
  
  <pre><code>vec3
  vec3_add(vec3 a, vec3 b) {
      static_assert(std::is_standard_layout&lt;vec3&gt;::value == true, "incompatible vec3 type");
      return vec3(a.x + b.x, a.y + b.y, a.z + b.z);
  }
  </code></pre>