0

When I try to compile my code it throws 66 errors and all the errors are just about mat4.h errors(repeating lines). I tried Include guards, #pragma once.

Code
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 File is too big so I will post it on pastebin. https://pastebin.com/FYSZV9ZX

  • Please ask if i missed some details in my code. –  Mar 16 '18 at 21:42
  • 1
    So what is the circular dependency you think may be causing this? What is the very first compiler error? – aschepler Mar 16 '18 at 21:43
  • First compile error is `missing type specifier - int assumed. Note: c++ does not support default-int` at line 31 in mat4.h –  Mar 16 '18 at 21:44
  • Without seeing an MCVE it's hard to tell but this is normally the solution: https://stackoverflow.com/questions/625799/resolve-build-errors-due-to-circular-dependency-amongst-classes – NathanOliver Mar 16 '18 at 21:44
  • 1
    @bananacoder Thank you. I forgot to check that. My vec3 and vec4 included unnecessary include. –  Mar 16 '18 at 21:46
  • Do vec3.h or vec4.h include Mat4.h by any chance? – HelloWorld Mar 16 '18 at 21:47
  • My answer is solved, but I have to wait 2 days to mark my post as answer –  Mar 16 '18 at 21:50

1 Answers1

0

Is your vec3 and vec4 headers including mat4?
If yes and it is unnecessary then remove that include.