title: error C2061: syntax error : identifier 'Robot'
body: <p><strong>QUESTION</strong> (answer below the question)</p>
  
  <p>I know there's lot of questions like mine, but I didn't find the solution for my problem anyway.</p>
  
  <p>I'w writing small project for school and everything was running with no problem until I added: <code>#include "robot.h"</code> into <strong>interface.h</strong> and added <code>, Robot* _robot</code> in <strong>init</strong> function in <strong>interface.h</strong>.</p>
  
  <p>I'm writing it with Visual Studio 2013 Ultimate <em>(I'm a student ;) )</em>. The whole code is accessible on <a href="https://github.com/Xkonti/RoboSim" rel="nofollow">github</a> and those are files written by me:</p>
  
  <ul>
  <li>allegroHelper.h .cpp - some functions for ease of use allegro library</li>
  <li>interface.h .cpp - class for drawing interface</li>
  <li>logic.h .cpp - logic of the robot</li>
  <li>robot.h .cpp - robot class</li>
  <li>libs/xkontiTextUtils.h .cpp - some fancy console functions (some are broken)</li>
  <li>libs/xkontiVector2d.h .cpp - little vector class</li>
  </ul>
  
  <p>The thing that is breaking my code is there:</p>
  
  <pre><code>//interface.h
  #pragma once
  
  
  //////////////////////////////////////////
  // INCLUDES
  //////////////////////////////////////////
  
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include "libs/xkontiTextUtils.h"
  #include "libs/xkontiVector2d.h"
  #include &lt;allegro5/allegro.h&gt;
  #include "allegro5/allegro_image.h"
  #include &lt;allegro5/allegro_primitives.h&gt;
  #include "robot.h"
  //#include "allegroHelper.h"    // Not needed due to forward declatation?
  
  
  //////////////////////////////////////////
  // INTERFACE CLASS
  //////////////////////////////////////////
  
  class Interface {
  public:
      Interface();
      ~Interface();
  
      bool init(std::string _mapPath, int _width, XkontiConsoleColors* _con, Robot* _robot);
      (...)
      Robot* robot;
      (...)
  };
  </code></pre>
  
  <p>Robot class is in <strong>robot.h</strong>:</p>
  
  <pre><code>//robot.h
  #pragma once
  
  
  //////////////////////////////////////////
  // INCLUDES
  //////////////////////////////////////////
  
  #include &lt;iostream&gt;
  
  #include &lt;vector&gt;
  #include &lt;math.h&gt;
  #include "libs/xkontiTextUtils.h"
  #include "libs/xkontiVector2d.h"
  
  #include &lt;allegro5/allegro.h&gt;
  #include "allegro5/allegro_image.h"
  #include &lt;allegro5/allegro_primitives.h&gt;
  
  #include "allegroHelper.h"
  
  
  //////////////////////////////////////////
  // ROBOT CLASS
  //////////////////////////////////////////
  
  class Robot {
  public:
      // Constuctor &amp; Destructor
      Robot(std::vector&lt; std::vector&lt;bool&gt; &gt;&amp; _map);
      ~Robot();
  
      // Initialization functions
      void initBody(Vector2D _size, Vector2D _pos, double _rotation, double _maxVelocity, double _maxAVelocity);
      void initHead(Vector2D _pos, Vector2D _rotRange, double _rangeMin, double _rangeMax, double _rangeError, unsigned int _resolution, double _rangeLess, double _rangeOver);
  
      // Set Functions
      void setPos(Vector2D _newPos);
      void setPos(double _x, double _y);
      void setRotation(double _rad);
  
      // Get Functions
      Vector2D getPos();
      Vector2D getHeadPos();
      double getRotation();
      int getStatus();
  
      // Commands Functions
      void move(double _dist);                // Move robot forward by specified distance
      void move(double _dist, double _rad);   // Move and turn robot
      void turn(double _rad);             // Turn robot by specified degree value
      std::vector&lt;double&gt;&amp; scan();        // Scans terrain. Returns reference to vector of distances.
  
      // Periodical Functions
      void update(double dt);
      void draw(double dt);
  
      // Public Variables
      std::vector&lt;Vector2D&gt; scanPoints;
  
  private:
      // Body functions
  
      // Head functions
      double trace(double _rad);          // Measure distance from current position
  
      // Outside pointers
      std::vector&lt; std::vector&lt;bool&gt; &gt;&amp; map;
  
      // Body properties
      Vector2D size;      // Dimensions: Width, Length
      Vector2D pos;           // Position: X, Y
      double rotation;                    // Rotation: Z axis
      double leftDistance;                // Distance left to travel
      double leftRotation;                // Rotation left to rotate
      double maxVelocity;             // Max forward velocity
      double maxAVelocity;                // Max angular velocity on Z axis (left/right)
  
      // Head properties
      Vector2D headPos;           // Head position: X, Y
      Vector2D headRotRange;  // Head Z rotation range: from - to in deg
      double rangeMin;            // Minimum and Maximum detection range
      double rangeMax;
      double rangeError;          // Error percentage on range measuring
      unsigned int resolution;    // Number of traces in left/right scan
      double rangeLess;           // Number used when something was nearer than rangeMin
      double rangeOver;           // Number used when nothing was detected
  };
  </code></pre>
  
  <p>The error I'm getting from compiler:</p>
  
  <pre><code>1&gt;------ Build started: Project: RoboSim, Configuration: Debug Win32 ------
  1&gt;  robot.cpp
  1&gt;d:\xkonti\github\robosim\interface.h(28): error C2061: syntax error : identifier 'Robot'
  1&gt;d:\xkonti\github\robosim\interface.h(39): error C2143: syntax error : missing ';' before '*'
  1&gt;d:\xkonti\github\robosim\interface.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  1&gt;  logic.cpp
  1&gt;d:\xkonti\github\robosim\interface.h(28): error C2061: syntax error : identifier 'Robot'
  1&gt;d:\xkonti\github\robosim\interface.h(39): error C2143: syntax error : missing ';' before '*'
  1&gt;d:\xkonti\github\robosim\interface.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  1&gt;  xkontiVector2d.cpp
  1&gt;  Generating Code...
  1&gt;  Skipping... (no relevant changes detected)
  1&gt;  interface.cpp
  1&gt;  allegroHelper.cpp
  1&gt;  RoboSim.cpp
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I looked for circular dependencies with <code>#include</code> but:</p>
  
  <ol>
  <li>I use <code>#pragma once</code> in every header</li>
  <li>I found that I include <strong>interface.h</strong> in <strong>allegroHelper.h</strong> and <strong>allegroHelper.h</strong> in <strong>interface.h</strong> and it was compiling without problem for long time.</li>
  </ol>
  
  <p>Can you tell me what am I doing wrong? Or any hints what to check?</p>
  
  <p><strong>ANSWER</strong></p>
  
  <p>Ok. I dont have much time and because I didn't find any way to have pointer to Robot class in Interface, I'm accessing data by references to some data in Robot class.</p>
  
  <p>In main file:</p>
  
  <pre><code>//RoboSim.cpp
  std::vector&lt; std::vector&lt;bool&gt; &gt; map;
  std::vector&lt;Vector2D&gt; scanPoints;
  ALLEGRO_BITMAP* image = nullptr;
  (...)
  Interface inter = Interface(scanPoints);
  Robot robot = Robot(map, scanPoints);
  (...)
  </code></pre>
  
  <p>In Interface class:</p>
  
  <pre><code>//interface.h
  (...)
  class Interface {
  public:
      Interface(std::vector&lt;Vector2D&gt;&amp; _scanPoints);
      ~Interface();
      (...)
  private:
      XkontiConsoleColors* con;
      std::vector&lt;Vector2D&gt;&amp; scanPoints;
      (...)
  </code></pre>
  
  <p>In Robot class:</p>
  
  <pre><code>//robot.h
  (...)
  class Robot {
  public:
      // Constuctor &amp; Destructor
      Robot(std::vector&lt; std::vector&lt;bool&gt; &gt;&amp; _map, std::vector&lt;Vector2D&gt;&amp; scanPoints);
      ~Robot();
      (...)
      std::vector&lt; std::vector&lt;bool&gt; &gt;&amp; map;
      std::vector&lt;Vector2D&gt;&amp; scanPoints;
      (...)
  </code></pre>