<?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[Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008...]]></title><description><![CDATA[<p>Weiß jemand, warum hier ein Unterschied besteht?</p>
<pre><code class="language-cpp">unsigned __int64 RTCTest=0;
QueryPerformanceCounter((LARGE_INTEGER *)&amp;RTCTest);  //bekommt einen validen Wert
QueryPerformanceCounter((LARGE_INTEGER *)&amp;pHandle-&gt;RTCStartOfScan);  //bleibt auf dem Ursprungswert 0
</code></pre>
<p>Dieser Code hat in der Vergangenheit (VS6+VS2005) immer funktioniert, mit dem VS2008 ist es aber nun so, dass die Variable, die Member eines structs ist, keinen Wert mehr zugewiesen bekommt! Sonst gibt es keinen Unterschied, beide sind unsigned __int64. Die Aufrufe waren zwar an verschiedenen Stellen, aber ich habe sie testweise direkt untereinander gepackt und auch andere Member gleichen Typs ausprobiert. Die Werte habe ich beim Breakpoint in der Folgezeile und per OutputDebugString überprüft und anhand eines Datenhaltepunkt, der beweist, dass QueryPerformanceCounter die Variable nicht anrührt.</p>
<p>Mein Workaround ist jetzt der, dass ich mir den Wert mit einer lokalen Variable hole und per memcpy nach RTCStartOfScan kopiere. Funktioniert wenigstens...</p>
<p>Ich habe selten etwas so unlogisches erlebt. Wäre klasse, wenn mir das jemand erklären könnte...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/225445/seltsames-phänomen-bei-queryperformancecounter-und-large_integer-mit-vs2008</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 16:54:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/225445.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Oct 2008 13:53:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Thu, 23 Oct 2008 13:53:59 GMT]]></title><description><![CDATA[<p>Weiß jemand, warum hier ein Unterschied besteht?</p>
<pre><code class="language-cpp">unsigned __int64 RTCTest=0;
QueryPerformanceCounter((LARGE_INTEGER *)&amp;RTCTest);  //bekommt einen validen Wert
QueryPerformanceCounter((LARGE_INTEGER *)&amp;pHandle-&gt;RTCStartOfScan);  //bleibt auf dem Ursprungswert 0
</code></pre>
<p>Dieser Code hat in der Vergangenheit (VS6+VS2005) immer funktioniert, mit dem VS2008 ist es aber nun so, dass die Variable, die Member eines structs ist, keinen Wert mehr zugewiesen bekommt! Sonst gibt es keinen Unterschied, beide sind unsigned __int64. Die Aufrufe waren zwar an verschiedenen Stellen, aber ich habe sie testweise direkt untereinander gepackt und auch andere Member gleichen Typs ausprobiert. Die Werte habe ich beim Breakpoint in der Folgezeile und per OutputDebugString überprüft und anhand eines Datenhaltepunkt, der beweist, dass QueryPerformanceCounter die Variable nicht anrührt.</p>
<p>Mein Workaround ist jetzt der, dass ich mir den Wert mit einer lokalen Variable hole und per memcpy nach RTCStartOfScan kopiere. Funktioniert wenigstens...</p>
<p>Ich habe selten etwas so unlogisches erlebt. Wäre klasse, wenn mir das jemand erklären könnte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1603440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603440</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 23 Oct 2008 13:53:59 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Thu, 23 Oct 2008 14:20:37 GMT]]></title><description><![CDATA[<p>mehr code? vielleicht ein minimales, lauffähiges beispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1603455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603455</guid><dc:creator><![CDATA[moar!]]></dc:creator><pubDate>Thu, 23 Oct 2008 14:20:37 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Thu, 23 Oct 2008 14:47:07 GMT]]></title><description><![CDATA[<p>moar! schrieb:</p>
<blockquote>
<p>mehr code? vielleicht ein minimales, lauffähiges beispiel?</p>
</blockquote>
<p>Habe ich versucht, aber im kleinen Beispielprojekt funktioniert's. Ich poste es trotzdem mal, zum den Ablauf klarer zu machen, denn der ist im Grunde der gleiche (wenn auch aus Wesentliche reduziert). Irgendein Unterschied muss natürlich trotzdem noch vorhanden sein, keine Ahnung...</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef struct tag_Handle {
	unsigned __int64 RTCStartOfScan;
	unsigned __int64 RTCEndOfScan;

} T_Handle;

void CallQPC(T_Handle *handle) {
	unsigned __int64 local1;
	unsigned __int64 local2;
	QueryPerformanceCounter((LARGE_INTEGER*)&amp;local1);
	QueryPerformanceCounter((LARGE_INTEGER*)&amp;local2);
	QueryPerformanceCounter((LARGE_INTEGER*)&amp;handle-&gt;RTCStartOfScan);
	QueryPerformanceCounter((LARGE_INTEGER*)&amp;handle-&gt;RTCEndOfScan);
}

int main() {
	T_Handle *h;
	h=(T_Handle*)malloc(sizeof(T_Handle));
	memset(h,0,sizeof(T_Handle));
	CallQPC(h);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1603475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603475</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 23 Oct 2008 14:47:07 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Thu, 23 Oct 2008 20:58:03 GMT]]></title><description><![CDATA[<blockquote>
<p>Irgendein Unterschied muss natürlich trotzdem noch vorhanden sein, keine Ahnung...</p>
</blockquote>
<p>Wenn du den Unterschied gefunden hast wirst du vermutlich den Fehler gefunden haben. Logisch, hm?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1603661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603661</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 23 Oct 2008 20:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Fri, 24 Oct 2008 02:49:07 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<blockquote>
<p>Irgendein Unterschied muss natürlich trotzdem noch vorhanden sein, keine Ahnung...</p>
</blockquote>
<p>Wenn du den Unterschied gefunden hast wirst du vermutlich den Fehler gefunden haben. Logisch, hm?</p>
</blockquote>
<p>Tja, das sagt sich so leicht. Das ist ein Riesenprojekt, da könnte ich wahrscheinlich ein Leben lang suchen, ohne fündig zu werden... <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/1603851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603851</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Fri, 24 Oct 2008 02:49:07 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Fri, 24 Oct 2008 07:12:51 GMT]]></title><description><![CDATA[<p>Was sagt der Rückgabewert? Was sagt GetLastError?</p>
<p>Falsche Speicheradresse? Irgendeine Debug Ausgabe?</p>
<p>BTW: Warum verwendest Du nicht den im SDK verwendeten Typ LONGLONG? Außerdem hat LARGE_INTEGER auch QuadPart.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1603997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1603997</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 24 Oct 2008 07:12:51 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Fri, 24 Oct 2008 09:41:26 GMT]]></title><description><![CDATA[<p>Martin Richter schrieb:</p>
<blockquote>
<p>BTW: Warum verwendest Du nicht den im SDK verwendeten Typ LONGLONG? Außerdem hat LARGE_INTEGER auch QuadPart.</p>
</blockquote>
<p>Das ist ursprünglich nicht mein Code! Ich habe den übernommen und darf jetzt halt damit leben...</p>
<p>Der Rückgabewert war erwartungsgemäß FALSE, GetLastError hat &quot;Invalid access to memory location.&quot; zurückgegeben, was mich nicht wirklich weitergebracht hat, da das Handle und alle Member problemlos gelesen und geschrieben werden konnten. Zumindest hat mein Wissen und Verständnis nicht ausgereicht.</p>
<p>Ein Kollege ist aber drauf gekommen. Es lag am Alignment! Da sind ein paar #pragma pack Anweisungen, die das Alignment u.a. für die Handle-Struktur geändert haben. Als ich die struct-Deklaration aus dem push-pop-Block 'rausgenommen hatte, war alles wieder in Ordnung. Der Kollege vermutet, dass sich mit dem VS2008 vielleicht die Implementierung von QueryPerformanceCounter geändert hat (SSE-Kram o.ä.) und deshalb plötzlich der vorher funktionierende Code Probleme gemacht hat...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1604073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1604073</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Fri, 24 Oct 2008 09:41:26 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Fri, 24 Oct 2008 10:12:28 GMT]]></title><description><![CDATA[<p>Siehe auch:</p>
<p>&quot;Why does QueryPerformanceFrequency fail with error 998?&quot; <a href="http://bobmoore.mvps.org/Win32/w32tip75.htm" rel="nofollow">http://bobmoore.mvps.org/Win32/w32tip75.htm</a></p>
<p>Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1604081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1604081</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Fri, 24 Oct 2008 10:12:28 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Fri, 24 Oct 2008 10:29:00 GMT]]></title><description><![CDATA[<p>Mmacher schrieb:</p>
<blockquote>
<p>Siehe auch:</p>
<p>&quot;Why does QueryPerformanceFrequency fail with error 998?&quot; <a href="http://bobmoore.mvps.org/Win32/w32tip75.htm" rel="nofollow">http://bobmoore.mvps.org/Win32/w32tip75.htm</a></p>
<p>Martin</p>
</blockquote>
<p>Interessanter Link! Hätte ich den mal früher gekannt. Während der Typ ca. 1 Stunde gebraucht hat war es bei mir eher ein halber Tag... mit Hilfe...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1604093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1604093</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Fri, 24 Oct 2008 10:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Phänomen bei QueryPerformanceCounter und LARGE_INTEGER mit VS2008... on Sun, 26 Oct 2008 00:03:07 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Nicht jeder Prozessor (Intel/AMD/Via usw.) hat den Counter. Bevor QueryPerformanceIrgendwas aufgerufen wird immer erst checken, ob der Prozessor das überhaupt kann.</p>
<p>Gruß</p>
<p>Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1604916</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1604916</guid><dc:creator><![CDATA[chezzmatazz]]></dc:creator><pubDate>Sun, 26 Oct 2008 00:03:07 GMT</pubDate></item></channel></rss>