g-truc / glm

OpenGL Mathematics (GLM)
https://glm.g-truc.net
Other
9.05k stars 2.1k forks source link

Compile error when using glm module with standard library module. #1260

Open godxin999 opened 6 months ago

godxin999 commented 6 months ago

I use standard library module std in my opengl project and I ran into a problem. I pick up the necessary part as follows.

import std;
import glm;

int main(int argc, char** argv){
    glm::mat4 matrix(1.0f);
    glm::mat4 matrix2=glm::inverse(matrix);
    return 0;
}

After compiling the code, the compiler told the error message unrecoverable error importing module 'std': symbol 'float_denorm_style' has already been defined.

I use the default glm.cppm file in package and I build my project with xmake. The xmake.lua file is as follows.

add_rules("mode.debug", "mode.release")
set_languages("c++latest")
add_requires("glm 1.0.0")
target("test")
    set_kind("binary")
    set_policy("build.c++.modules", true)
    add_files("src/*.cpp", "src/*.cppm")
    add_packages("glm")

At last there are some details about my environment.