Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 649
Jozef Culen Avatar asked Feb 12 '15 22:02

Jozef Culen


1 Answers

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, already-aligned data.

void Shader::setUniform(const std::string &name, const glm::mat4 & value)
//                                               ^^^^^           ^
like image 101
Drew Dormann Avatar answered Nov 12 '22 03:11

Drew Dormann