其他分享
首页 > 其他分享> > c – 带有__declspec(align(’16’))的形式参数将不对齐

c – 带有__declspec(align(’16’))的形式参数将不对齐

作者:互联网

我正在尝试设置着色器制服的功能,但是当我尝试编译它时,我收到此错误:

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

这是功能代码:

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);
}

我正在使用Visual Studio 2013.

解决方法:

Microsoft’s documentation起就出现了这个错误:

The 07001 __declspec modifier is not permitted on function parameters.

请勿将参数复制到未对齐的位置.传递对现有对齐数据的恒定引用.

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

标签:glm-math,c,opengl
来源: https://codeday.me/bug/20190929/1830114.html