<?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[Zeiger zu long umwandeln!]]></title><description><![CDATA[<p>Wie kann ich den Zeiger eines Objekts zu einer long Variable umwandeln?<br />
So was:</p>
<pre><code class="language-cpp">class A {
public:
    A() {
        long p = this; // ??????? Wie?
    }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/187006/zeiger-zu-long-umwandeln</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 14:37:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187006.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Jul 2007 15:03:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 15:03:14 GMT]]></title><description><![CDATA[<p>Wie kann ich den Zeiger eines Objekts zu einer long Variable umwandeln?<br />
So was:</p>
<pre><code class="language-cpp">class A {
public:
    A() {
        long p = this; // ??????? Wie?
    }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1325366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325366</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Sat, 14 Jul 2007 15:03:14 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 15:05:16 GMT]]></title><description><![CDATA[<p>Im obigen Fall brauchst du in A einen operator long(.....) der den Typ A in long umwandelt und dann:</p>
<pre><code class="language-cpp">long temp = dynamic_cast&lt;long&gt;(*this);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1325369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325369</guid><dc:creator><![CDATA[Balmung]]></dc:creator><pubDate>Sat, 14 Jul 2007 15:05:16 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 15:09:32 GMT]]></title><description><![CDATA[<p>tuts nicht auch nen reinterpret_cast&lt;long&gt;(this)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325370</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325370</guid><dc:creator><![CDATA[thordk]]></dc:creator><pubDate>Sat, 14 Jul 2007 15:09:32 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 15:13:18 GMT]]></title><description><![CDATA[<p>thordk schrieb:</p>
<blockquote>
<p>tuts nicht auch nen reinterpret_cast&lt;long&gt;(this)?</p>
</blockquote>
<p>Yuppie! Das funzt!<br />
Jetzt will ich wissen wie ich aus long, den Zeiger kriege! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325372</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Sat, 14 Jul 2007 15:13:18 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 15:39:38 GMT]]></title><description><![CDATA[<p>genauso.</p>
<pre><code class="language-cpp">struct A
{
  long ptr() {
    return reinterpret_cast&lt;long&gt;(this);
  }
};

int main() {
  A a;
  long l = a.ptr();
  A *b;
  b = reinterpret_cast&lt;A*&gt;(l);
}
</code></pre>
<p>aber bevor du das so verwendest, soll jemand mit mehr reinterpret_cast ahnung als ich sein OK geben ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325392</guid><dc:creator><![CDATA[thordk]]></dc:creator><pubDate>Sat, 14 Jul 2007 15:39:38 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 23:40:37 GMT]]></title><description><![CDATA[<p>Als Typ würde ich eher ptrdiff_t oder size_t empfehlen. Auf Systemen mit zB LLP64 Datenmodell (Win64) hast du mit long ein Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325598</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sat, 14 Jul 2007 23:40:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 23:42:44 GMT]]></title><description><![CDATA[<p>Aber wofür willst du einen Zeiger in einer long-Variable speichern? Abgesehen davon, dass glaubich gar nicht gesichtert ist, dass der Zeiger auch reinpasst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325599</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 14 Jul 2007 23:42:44 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sat, 14 Jul 2007 23:48:36 GMT]]></title><description><![CDATA[<p>Badestrand schrieb:</p>
<blockquote>
<p>Aber wofür willst du einen Zeiger in einer long-Variable speichern?</p>
</blockquote>
<p>ZB um mehr Freiheit bei der Adressmodifizierung zu haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325600</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sat, 14 Jul 2007 23:48:36 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sun, 15 Jul 2007 00:28:19 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>Badestrand schrieb:</p>
<blockquote>
<p>Aber wofür willst du einen Zeiger in einer long-Variable speichern?</p>
</blockquote>
<p>ZB um mehr Freiheit bei der Adressmodifizierung zu haben.</p>
</blockquote>
<p>Äh?</p>
<p>So etwas macht man nicht!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325610</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Sun, 15 Jul 2007 00:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sun, 15 Jul 2007 05:21:19 GMT]]></title><description><![CDATA[<p>Ich benutze gerade Win32 API. Dort kann man beim Erstellen eines Windows zusätzlich Speicherplatz reservieren. Ich habe 8 Bytes festgelegt. Darin kann man beliebige Daten speichern. Leider sind die get/set Funktionen mit long versehen. D.h., wenn ich einen Zeiger speichern/lesen will, muss ich immer diese hässliche Konvertierung machen! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1325641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1325641</guid><dc:creator><![CDATA[khalderon]]></dc:creator><pubDate>Sun, 15 Jul 2007 05:21:19 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sun, 15 Jul 2007 20:17:35 GMT]]></title><description><![CDATA[<p>rüdiger schrieb:</p>
<blockquote>
<p>Äh?</p>
<p>So etwas macht man nicht!</p>
</blockquote>
<p>Doch, macht man schon, sofern man es braucht. Einfach mal ein bisschen über simple Zeigerarithmetik hinaus denken. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1326119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1326119</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 15 Jul 2007 20:17:35 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sun, 15 Jul 2007 20:20:45 GMT]]></title><description><![CDATA[<p>Zdravko schrieb:</p>
<blockquote>
<p>Ich benutze gerade Win32 API. Dort kann man beim Erstellen eines Windows zusätzlich Speicherplatz reservieren. Ich habe 8 Bytes festgelegt. Darin kann man beliebige Daten speichern. Leider sind die get/set Funktionen mit long versehen. D.h., wenn ich einen Zeiger speichern/lesen will, muss ich immer diese hässliche Konvertierung machen! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
</blockquote>
<p>also wieder einer der grauenvollen designfehler von win32</p>
<p>warum nicht einfach eine lib benutzen die das ganze weniger hirnverbrannt macht</p>
<p>(winapi nutzen macht imho nur sinn, wen __explizit__ verlangt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1326123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1326123</guid><dc:creator><![CDATA[ronny]]></dc:creator><pubDate>Sun, 15 Jul 2007 20:20:45 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger zu long umwandeln! on Sun, 15 Jul 2007 20:33:27 GMT]]></title><description><![CDATA[<p>Wo genau ist da ein Design Fehler?</p>
<p>Edit:<br />
es handelt sich übrigens nicht um den C++ Datentyp long sondern um das typedef LONG_PTR dass garantiert die größe hat um einen Zeiger aufnehmen zu können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1326128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1326128</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Sun, 15 Jul 2007 20:33:27 GMT</pubDate></item></channel></rss>