Question

I am getting a confusing C4430 missing type specifier error for all uses of Vector4D. I don't understand why it's being thrown. It's declared. It's defined. It exists. It is well-formed. (I commented out all uses and includes other than the class definition/declaration, the code compiled.) and it is included.

The code as-is works in VS2012 but not VS2010.

Here is a sample of the uses in the Vector2D class. There are similar for Vector3D including Vector4D GetHomogeneous() const; et. al.

#ifndef A2DE_CVECTOR2D_H
#define A2DE_CVECTOR2D_H

#include "../a2de_vals.h"
#include "CMiscMath.h"

#include "CVector3D.h"
#include "CVector4D.h"

A2DE_BEGIN

class Vector2D {

public:

    Vector2D();
    Vector2D(double x, double y);
    Vector2D(const Vector2D& vector);
    Vector2D(const Vector3D& v3d);
    Vector2D(const Vector4D& v4d);
    Vector2D(const Math::PolarCoordinate& magnitude_and_angle);
    ~Vector2D();
    double GetX() const;
    double GetX();
    double GetY() const;
    double GetY();
    double GetLength() const;
    double GetLength();
    double GetLengthSquared() const;
    double GetLengthSquared();
    double DotProduct(const Vector2D& rhs) const;
    static double DotProduct(const Vector2D& a, const Vector2D& b);
    Vector2D Normalize() const;
    static void Normalize(Vector2D& v);
    Vector2D GetLeftNormal() const;
    Vector2D GetLeftNormal();
    Vector2D GetRightNormal() const;
    Vector2D GetRightNormal();
    Vector2D GetProjection(const Vector2D& b);
    static Vector2D GetProjection(const Vector2D& a, const Vector2D& b);
    Vector2D GetProjectionOnXAxis();
    Vector2D GetProjectionOnYAxis();
    double GetAngle() const;
    double GetAngle();
    static double GetAngle(const Vector2D& v);
    double GetAngleFrom(const Vector2D& b);
    static double GetAngleFrom(const Vector2D& b, const Vector2D& a);
    static double GetFacingAngle(const Vector2D& target, const Vector2D& source);
    static Vector2D GetFacingVector(const Vector2D& target, const Vector2D& source);
    Vector2D& operator=(const Vector2D& rhs);
    Vector2D& operator=(const Vector3D& rhs);
    Vector2D& operator=(const Vector4D& rhs);
    bool operator==(const Vector2D& rhs);
    bool operator==(const Vector2D& rhs) const;
    bool operator!=(const Vector2D& rhs);
    bool operator!=(const Vector2D& rhs) const;
    Vector2D& operator+=(double scalar);
    Vector2D& operator-=(double scalar);
    Vector2D& operator*=(double scalar);
    Vector2D& operator/=(double scalar);
    Vector2D operator+(const Vector2D& rhs) const;
    Vector2D operator+(const Vector2D& rhs);
    Vector2D operator-(const Vector2D& rhs) const;
    Vector2D operator-(const Vector2D& rhs);
    Vector2D operator-();
    Vector2D operator*(const Vector2D& rhs) const;
    Vector2D operator*(const Vector2D& rhs);
    Vector2D operator/(const Vector2D& rhs) const;
    Vector2D operator/(const Vector2D& rhs);
    Vector2D& operator+=(const Vector2D& rhs);
    Vector2D& operator-=(const Vector2D& rhs);
    Vector2D& operator*=(const Vector2D& rhs);
    Vector2D& operator/=(const Vector2D& rhs);
    operator Vector3D();
    operator Vector4D();
    Vector3D GetHomogeneous() const;
    Vector3D GetHomogeneous();
    friend Vector2D operator+(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator+(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator-(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator-(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator*(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator*(double scalar_lhs, const Vector2D& v_rhs);
    friend Vector2D operator/(const Vector2D& v_lhs, double scalar_rhs);
    friend Vector2D operator/(double scalar_lhs, const Vector2D& v_rhs);

protected:

    void SetX(double x);
    void SetY(double y);
    void SetTerminal(double x, double y);

    double _x;
    double _y;
    double _angle;

private:
};


A2DE_END

#endif
Was it helpful?

Solution

Including similar types in header files is leading me to think you may have circular dependencies. It is recommended to use forward declarations in headers, and it appears from your Vector2D definition that instead of the #includes, you can simply use:

class Vector3D;
class Vector4D;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top