C++ 奇怪的循环依赖错误

C++ Strange Circular Dependecy error

当我尝试编译我的代码时,它抛出 66 个错误,所有错误都是大约 mat4.h 个错误(重复行)。我试过包括守卫,#pragma once.

代码
mat4.h

#pragma once

#include "vec3.h"
#include "vec4.h"
#include "maths_func.h"

namespace sparky { namespace maths {

   struct mat4
   {
        union
        {
            float elements[4 * 4];
            vec4 columns[4];
        };

        mat4();
        mat4(float diagonal);

        static mat4 identity();
        mat4& multiply(const mat4& other);

        friend mat4 operator*(mat4 left, const mat4& right);
        mat4& operator*=(const mat4& other);

        mat4& Invert();

        static mat4 orthographic(float left, float right, float bottom, float top, float near, float far);
        static mat4 perspective(float fov, float aspectRatio, float near, float far);

        static mat4 translation(const vec3& translation);
        static mat4 rotation(float angle, const vec3& axis);
        static mat4 scale(const vec3& scale);
    };
} }

mat4.cpp 文件太大,所以我将 post 放在 pastebin 上。 https://pastebin.com/FYSZV9ZX

你的 vec3 和 vec4 headers 包括 mat4 吗?
如果是并且不需要,则删除包含的内容。