Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue declaring extern class object
    primarykey
    data
    text
    <p>Let me start by saying I've extensively searched for answers on google and more specifically here.</p> <p>The thing is I actually (at least I think I did) found people with similar problems, though the answer given to them gave me another problem.</p> <p>I'm using Visual Studio 2010 Express and working with SFML libary (though i do not think this last part is relevant)</p> <p>So here it goes:</p> <p>I have a source file called player.cpp which holds class Player and I have a header file (included in all source files) called cc.h(command and control) that holds all the necessary includes and external variables/functions. The essential code can be summed up in the following:</p> <p>Player.cpp:</p> <pre><code>#include "cc.h" class Player { private: //some variables here public: //more variables and some functions }john;//example instance </code></pre> <p>cc.h:</p> <pre><code>#pragma once //some #includes //some externs extern Player john; </code></pre> <p>Now in cc.h the word Player is underlined as a mistake saying it is an <em>undefined identifier</em> , but only sometimes, other times visual studio doesn't mark it as a mistake, instead it recognizes it as a class but doesn't recognize john as an object/instance (i hope it's called this way) of that same class. Furthermore, at compiling the first error it shows is "<code>error C2146: syntax error : missing ';' before identifier 'john'</code>" at the line of the extern declaration of john, in cc.h, which apparently (to me) does not make any sense.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload