Jozef Culen Jozef Culen - 2 months ago 11x
C++ Question

c++/Opengl: formal parameter with __declspec(align('16')) won't be aligned

I am trying to make function for setting shader uniforms, but when I try to compile it I get this error :

Error 2 error C2719: 'value': formal parameter with
__declspec(align('16')) won't be aligned

Here is code of function:

void Shader::setUniform(std::string name, const glm::mat4 value){
GLint uniform = glGetUniformLocation(m_program, name.c_str());
glUniformMatrix4fv(uniform, 1, GL_FALSE, (GLfloat*)&value);

I am using Visual studio 2013.


From Microsoft's documentation on that error:

The align __declspec modifier is not permitted on function parameters.

Don't copy the parameter to an unaligned location. Pass a constant reference to the existing, aligned data.

void Shader::setUniform(const std::string &name, const glm::mat4 &value)
//                                               ^^^^^           ^