Jump to content

incorrect "pass by value" in example code


photo

Recommended Posts

Hello,

In some code sample in the documentation, you use "pass by value" instead of "pass by const&" in C++ code for complex aligned structure.

Example in https://developer.unigine.com/en/docs/2.6/code/usage/cloth_particle_joint/

// incorrect
ObjectMeshDynamicPtr createSphere(char *name, float radius, vec4 color, vec3 pos)

// correct
ObjectMeshDynamicPtr createSphere(char *name, float radius, const vec4& color, const vec3& pos)

The incorrect way leads to this error (tested with VC2015): 

AppWorldLogic.cpp(18): error C2719: 'color': formal parameter with requested alignment of 16 won't be aligned

 

Link to comment
×
×
  • Create New...