<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem mit extern]]></title><description><![CDATA[<p>Ich bekomme mein Programm nicht zum Laufen. Verwende ich &quot;extern&quot; falsch?<br />
Ich kann leider nicht so viel mit den Fehlermeldungen anfangen.</p>
<pre><code>1&gt;P1Map.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: int __thiscall P1Player::GetY(void)&quot; (?GetY@P1Player@@QAEHXZ)&quot; in Funktion &quot;&quot;public: void __thiscall P1TileMap::Draw(void)&quot; (?Draw@P1TileMap@@QAEXXZ)&quot;.
1&gt;P1Map.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: int __thiscall P1Player::GetX(void)&quot; (?GetX@P1Player@@QAEHXZ)&quot; in Funktion &quot;&quot;public: void __thiscall P1TileMap::Draw(void)&quot; (?Draw@P1TileMap@@QAEXXZ)&quot;.
1&gt;P1WinMain.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall P1Game::P1Game(void)&quot; (??0P1Game@@QAE@XZ)&quot; in Funktion &quot;&quot;void __cdecl `dynamic initializer for 'Game''(void)&quot; (??__EGame@@YAXXZ)&quot;.
1&gt;P1WinMain.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall P1Game::~P1Game(void)&quot; (??1P1Game@@QAE@XZ)&quot; in Funktion &quot;&quot;void __cdecl `dynamic atexit destructor for 'Game''(void)&quot; (??__FGame@@YAXXZ)&quot;.
</code></pre>
<p>P1Include.h:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

// Konstanten &amp; Methoden
#include &quot;P1Constants.h&quot;
#include &quot;P1Methods.h&quot;

// DirectX
#pragma comment (lib, &quot;d3d9.lib&quot;)
#include &lt;d3d9.h&gt;

// Klassen
#include &quot;P1Graphics.h&quot;
#include &quot;P1Game.h&quot;
#include &quot;P1Map.h&quot;
#include &quot;P1Player.h&quot;

// Global verfügbar machen
extern P1Game   Game;
extern P1Player Player;
</code></pre>
<p>P1WinMain.h:</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

P1Game Game;
P1Player Player;

int CALLBACK WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow) 
{

  return 0;
}
</code></pre>
<p>P1Map.cpp:</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

void P1TileMap::Draw() 
{
  int iPlrViewX = BoundBy(Player.GetX() - iViewWidth / 2, 0, iMapWidth - iViewWidth);
  int iPlrViewY = BoundBy(Player.GetY() - iViewHeight / 2, 0, iMapHeight - iViewHeight);

  for(int iY = iPlrViewX - iPlrViewX % iTileHeight; iY &lt; iMapHeight; iY += iTileHeight) {
    for(int iX = iPlrViewY - iPlrViewY % iTileWidth; iX &lt; iMapWidth; iX += iTileWidth) {
      P1Tile Tile = GetTile(iX, iY);
      // TODO: Tile zeichnen
    }
  }
}
</code></pre>
<p>P1Player.h:</p>
<pre><code class="language-cpp">class P1Player
{
  private:
    int iX, iY;

  public:
    P1Player();
    P1Player(int, int);
    ~P1Player();

  public:
    int GetX();
    int GetY();
};
</code></pre>
<p>P1Player.cpp</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

/* -- Konstruktoren und Destruktoren -- */
P1Player::P1Player() {}
P1Player::P1Player(int iParX, int iParY) : iX(iParX), iY(iParY) {}
P1Player::~P1Player() {}

/* -- Methoden -- */
inline int P1Player::GetX() 
{
  return iX;
}

inline int P1Player::GetY() 
{
  return iY;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/275983/problem-mit-extern</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 14:36:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/275983.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 24 Oct 2010 18:13:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit extern on Sun, 24 Oct 2010 18:13:09 GMT]]></title><description><![CDATA[<p>Ich bekomme mein Programm nicht zum Laufen. Verwende ich &quot;extern&quot; falsch?<br />
Ich kann leider nicht so viel mit den Fehlermeldungen anfangen.</p>
<pre><code>1&gt;P1Map.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: int __thiscall P1Player::GetY(void)&quot; (?GetY@P1Player@@QAEHXZ)&quot; in Funktion &quot;&quot;public: void __thiscall P1TileMap::Draw(void)&quot; (?Draw@P1TileMap@@QAEXXZ)&quot;.
1&gt;P1Map.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: int __thiscall P1Player::GetX(void)&quot; (?GetX@P1Player@@QAEHXZ)&quot; in Funktion &quot;&quot;public: void __thiscall P1TileMap::Draw(void)&quot; (?Draw@P1TileMap@@QAEXXZ)&quot;.
1&gt;P1WinMain.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall P1Game::P1Game(void)&quot; (??0P1Game@@QAE@XZ)&quot; in Funktion &quot;&quot;void __cdecl `dynamic initializer for 'Game''(void)&quot; (??__EGame@@YAXXZ)&quot;.
1&gt;P1WinMain.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall P1Game::~P1Game(void)&quot; (??1P1Game@@QAE@XZ)&quot; in Funktion &quot;&quot;void __cdecl `dynamic atexit destructor for 'Game''(void)&quot; (??__FGame@@YAXXZ)&quot;.
</code></pre>
<p>P1Include.h:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

// Konstanten &amp; Methoden
#include &quot;P1Constants.h&quot;
#include &quot;P1Methods.h&quot;

// DirectX
#pragma comment (lib, &quot;d3d9.lib&quot;)
#include &lt;d3d9.h&gt;

// Klassen
#include &quot;P1Graphics.h&quot;
#include &quot;P1Game.h&quot;
#include &quot;P1Map.h&quot;
#include &quot;P1Player.h&quot;

// Global verfügbar machen
extern P1Game   Game;
extern P1Player Player;
</code></pre>
<p>P1WinMain.h:</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

P1Game Game;
P1Player Player;

int CALLBACK WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow) 
{

  return 0;
}
</code></pre>
<p>P1Map.cpp:</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

void P1TileMap::Draw() 
{
  int iPlrViewX = BoundBy(Player.GetX() - iViewWidth / 2, 0, iMapWidth - iViewWidth);
  int iPlrViewY = BoundBy(Player.GetY() - iViewHeight / 2, 0, iMapHeight - iViewHeight);

  for(int iY = iPlrViewX - iPlrViewX % iTileHeight; iY &lt; iMapHeight; iY += iTileHeight) {
    for(int iX = iPlrViewY - iPlrViewY % iTileWidth; iX &lt; iMapWidth; iX += iTileWidth) {
      P1Tile Tile = GetTile(iX, iY);
      // TODO: Tile zeichnen
    }
  }
}
</code></pre>
<p>P1Player.h:</p>
<pre><code class="language-cpp">class P1Player
{
  private:
    int iX, iY;

  public:
    P1Player();
    P1Player(int, int);
    ~P1Player();

  public:
    int GetX();
    int GetY();
};
</code></pre>
<p>P1Player.cpp</p>
<pre><code class="language-cpp">#include &quot;P1Include.h&quot;

/* -- Konstruktoren und Destruktoren -- */
P1Player::P1Player() {}
P1Player::P1Player(int iParX, int iParY) : iX(iParX), iY(iParY) {}
P1Player::~P1Player() {}

/* -- Methoden -- */
inline int P1Player::GetX() 
{
  return iX;
}

inline int P1Player::GetY() 
{
  return iY;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1970086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970086</guid><dc:creator><![CDATA[Tappich]]></dc:creator><pubDate>Sun, 24 Oct 2010 18:13:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit extern on Sun, 24 Oct 2010 18:36:11 GMT]]></title><description><![CDATA[<p>Mit &quot;extern&quot; haben Deine Fehler nicht viel zu tun.</p>
<p>Es werden folgende fehlende Definitionen angemeckert:</p>
<pre><code>public: int P1Player::GetY(void)
public: int P1Player::GetX(void)
public: P1Game::P1Game(void)
public: P1Game::~P1Game(void)
</code></pre>
<p>Die Definition der letzten beiden Funktionen kann ich nirgends wo sehen. Aber die ersten beiden wurden in P1Player.cpp definiert. Der Fehler ist hier, dass Du &quot;inline&quot; falsch benutzt hast. Denn die Funktion ist sonst nirgends wo als Inline-Funktion deklariert, nur in dieser einen Übersetzungseinheit. Das ist nicht erlaubt. Wenn das eine inline-Funktion sein soll, muss sie auch dementsprechend in anderen ÜEs als <em>solche</em> deklariert werden. Und wenn in einer ÜE eine Funktion als inline-Funktion deklariert ist und benutzt wird, <em>muss</em> auch eine Definition in derselben ÜE vorhanden sein. So will es die &quot;ODR&quot; (one definition rule). <em>Praktisch</em> heißt das, dass Du sie im Header als inline-Funktion <em>definieren</em> oder das inline-Schlüsselwort bei der Definition in der einen cpp-Datei entfernen musst.</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970098</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Sun, 24 Oct 2010 18:36:11 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit extern on Sun, 24 Oct 2010 19:00:57 GMT]]></title><description><![CDATA[<p>Danke schonmal für die Antwort. Wenn ich inline entferne, dann funktioniert mein Code. Aber ich würde gerne inline verwenden. Wie stelle ich das an?</p>
<p>Langt es, wenn ich vor der Methode in der Header Datei inline schreibe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970110</guid><dc:creator><![CDATA[Tappich]]></dc:creator><pubDate>Sun, 24 Oct 2010 19:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit extern on Sun, 24 Oct 2010 19:17:51 GMT]]></title><description><![CDATA[<p>Tappich schrieb:</p>
<blockquote>
<p>Aber ich würde gerne inline verwenden. Wie stelle ich das an?<br />
Langt es, wenn ich vor der Methode in der Header Datei inline schreibe?</p>
</blockquote>
<p>Habe ich alles schon beantwortet:</p>
<p>krümelkacker schrieb:</p>
<blockquote>
<p>... Wenn das eine inline-Funktion sein soll, muss sie auch dementsprechend in anderen ÜEs als solche deklariert werden. Und wenn in einer ÜE eine Funktion als inline-Funktion deklariert ist und benutzt wird, muss auch eine Definition in derselben ÜE vorhanden sein. So will es die &quot;ODR&quot; (one definition rule). <em>Praktisch</em> heißt das, dass Du sie im Header als inline-Funktion <em>definieren</em> oder das inline-Schlüsselwort bei der Definition in der einen cpp-Datei entfernen musst.</p>
</blockquote>
<p>Aber vielleicht ist Dir etwas von der Terminologie nicht ganz klar. Also:</p>
<pre><code>void foo();    // &lt;-- reine [b]Deklaration[/b]
void foo() {}  // &lt;--       [b]Definition[/b] (gleichzeitig Deklaration)
</code></pre>
<p>ÜE = Übersetzungeinheit = das, was der <a href="http://de.wikipedia.org/wiki/C-Pr%C3%A4prozessor" rel="nofollow">Präprozessor</a> ausgehend von einer cpp-Datei (mit allen &quot;Includes&quot; (rekursiv) und Makro-Ersetzungen) dem eigentlichen Compiler zum Fraß vorwirft.</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970118</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Sun, 24 Oct 2010 19:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit extern on Sun, 24 Oct 2010 19:59:33 GMT]]></title><description><![CDATA[<p>Okay, dann wäre alles geklärt. Danke Dir krümelkacker <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970132</guid><dc:creator><![CDATA[Tappich]]></dc:creator><pubDate>Sun, 24 Oct 2010 19:59:33 GMT</pubDate></item></channel></rss>