<?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[Multithreading mit Parameter]]></title><description><![CDATA[<p>Ich hätt mal ne kurze Frage zu dieser process.h - Multithreading Lib</p>
<p>Habe folgendes geschrieben:</p>
<pre><code class="language-cpp">class GlobalVariables {

public:
	GlobalVariables();
	~GlobalVariables();
        //...
private:
        //...
}
</code></pre>
<pre><code class="language-cpp">//Funktion / thread
void DisplayManager (void * GV) {
     // .....do something with GV
}

// in der main aufgerufen
_beginthread(DisplayManager, 0, (void *) GV );
</code></pre>
<p>Bekomme die Fehlermeldung:</p>
<p>- Der Ausdruck muss einen klassentyp aufweisen<br />
- GlobalVariables kann nicht in *void konvertiert werden</p>
<p>Was habe ich falsch gemacht?</p>
<p>Lg Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305801/multithreading-mit-parameter</link><generator>RSS for Node</generator><lastBuildDate>Sat, 08 Aug 2026 12:25:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305801.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Jul 2012 09:30:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 09:30:58 GMT]]></title><description><![CDATA[<p>Ich hätt mal ne kurze Frage zu dieser process.h - Multithreading Lib</p>
<p>Habe folgendes geschrieben:</p>
<pre><code class="language-cpp">class GlobalVariables {

public:
	GlobalVariables();
	~GlobalVariables();
        //...
private:
        //...
}
</code></pre>
<pre><code class="language-cpp">//Funktion / thread
void DisplayManager (void * GV) {
     // .....do something with GV
}

// in der main aufgerufen
_beginthread(DisplayManager, 0, (void *) GV );
</code></pre>
<p>Bekomme die Fehlermeldung:</p>
<p>- Der Ausdruck muss einen klassentyp aufweisen<br />
- GlobalVariables kann nicht in *void konvertiert werden</p>
<p>Was habe ich falsch gemacht?</p>
<p>Lg Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231205</guid><dc:creator><![CDATA[Lars1234]]></dc:creator><pubDate>Mon, 09 Jul 2012 09:30:58 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 09:33:14 GMT]]></title><description><![CDATA[<p>Also GV ist ein solches Klassenobjekt und soll von der Main in den thread geschickt werden! Laut einem Internet-Tutorial soll das so gehen, ich kriegs aber nicht hin...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231206</guid><dc:creator><![CDATA[Lars1234]]></dc:creator><pubDate>Mon, 09 Jul 2012 09:33:14 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 09:38:25 GMT]]></title><description><![CDATA[<p>Dein Angaben sind ziemlich dürr, ich würde aber mal vermuten, dass du keinen Zeiger hast. Es müsste also so lauten:</p>
<pre><code class="language-cpp">_beginthread(DisplayManager, 0, (void *) &amp;GV );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2231212</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231212</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 09 Jul 2012 09:38:25 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 09:48:09 GMT]]></title><description><![CDATA[<p>Ah ok das ist ein bisschen peinlich^^<br />
Schonmal Danke für deine schnelle Hilfe!</p>
<p>Wie verwende ich jetzt die Klasse in meinem Thread?</p>
<pre><code class="language-cpp">cout &lt;&lt;  GV.GetCurrentTemperature() &lt;&lt; endl;
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">cout &lt;&lt; (GlobalVariables) GV.GetCurrentTemperature() &lt;&lt; endl;
</code></pre>
<p>er scheint beide Varianten nicht zu kennen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title="=/"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231217</guid><dc:creator><![CDATA[Lars1234]]></dc:creator><pubDate>Mon, 09 Jul 2012 09:48:09 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 10:04:10 GMT]]></title><description><![CDATA[<p>Also hier mal etwas mehr Source-Code, damit mein Problem eventuell klarer wird:</p>
<pre><code class="language-cpp">//----------------------------------------------------
// Main - Funktion
//----------------------------------------------------
int main () {

	Login();

	bool forever = true;
	GlobalVariables GV;

	while (forever) {
		_beginthread(DisplayManager, 0, (void *) &amp;GV );
		Sleep(100);
	} 

	_endthread();		
	return 0;
}
</code></pre>
<pre><code class="language-cpp">//----------------------------------------------------
// DisplayManager: wartet auf Tastendruck der Pfeile
//----------------------------------------------------
void DisplayManager (void * GV) {		

	char input = getch();	

	if(input == '1') {				
		screen++;
		if (screen &gt; 5) screen = 0;
	}
	else if(input == '2') {			
		screen--; 
		if (screen &lt; 0) screen = 5;
	}
	else { 
		cout &lt;&lt; &quot;Error: Unknown Input\n&quot;; 
	}

	if(screen == 0) { 
		cout &lt;&lt; &quot;Temperatur-Ist-Wert\n&quot;; 
		//cout &lt;&lt; (GlobalVariables) GV.GetCurrentTemperature() &lt;&lt; endl;
	}
	else if(screen == 1) { 
		cout &lt;&lt; &quot;Temperatur-Soll-Wert\n&quot;; 
		//cout &lt;&lt; (GlobalVariables) GV.GetTargetTemperature() &lt;&lt; endl;
	}
	else if(screen == 2) { 
		cout &lt;&lt; &quot;Ventilator/Drehzahl\n&quot;; 
	}
        //.........

	}
	else if(screen == 5) { 
		cout &lt;&lt; &quot;Admin: Ausschaltverz\x94gerung\n&quot;; 
	}
	else { 
		cout &lt;&lt; &quot;Error: Unknown Screen\n&quot;; 
	}
}
</code></pre>
<pre><code class="language-cpp">class GlobalVariables {

public:
	GlobalVariables();
	~GlobalVariables();

	int GetCurrentTemperature() const {return CurrentTemperature;}
	void SetCurrentTemperature(int const &amp; Val) { CurrentTemperature = Val;}

private:
	int CurrentTemperature;
};
</code></pre>
<p>Hoffe der Code bringt klarheit über mein problem?<br />
Danke für alle beiträge!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231226</guid><dc:creator><![CDATA[Lars1234]]></dc:creator><pubDate>Mon, 09 Jul 2012 10:04:10 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 10:12:39 GMT]]></title><description><![CDATA[<p>Lars, willkommen im Forum.<br />
Lies dir bitte folgenden <a href="http://www.c-plusplus.net/forum/304133" rel="nofollow">Link</a> durch.</p>
<p>Anschließend entferne dich schnell von diesem lächerlichen Internettutorial, dass dir nur falsche Grundlagen vermittelt, und hol dir ein gutes Buch.</p>
<p>Mehr kann man dazu auch nicht sagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231231</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 09 Jul 2012 10:12:39 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 10:20:20 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//----------------------------------------------------
// DisplayManager: wartet auf Tastendruck der Pfeile
//----------------------------------------------------
void DisplayManager (void * GV) {       
   GlobalVariables gv = *(GlobalVariables*) GV;

   ...

   cout &lt;&lt;  gv.GetCurrentTemperature() &lt;&lt; endl;

   ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2231236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231236</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Mon, 09 Jul 2012 10:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 10:51:35 GMT]]></title><description><![CDATA[<p>Das macht man mit static_cast in beiden Richtungen und bitte auch ohne das Kopieren des GlobalVariables-Objekts:</p>
<pre><code>void DisplayManager (void * GVraw)
{
   assert(GVraw);
   GlobalVariables gv = [b]static_cast&lt;GlobalVariables*&gt;[/b](GVraw);

   ...

   cout &lt;&lt;  gv-&gt;GetCurrentTemperature() &lt;&lt; endl;

   ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2231244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231244</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 09 Jul 2012 10:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 11:15:59 GMT]]></title><description><![CDATA[<p>Hör auf eine nicht portable 20 Jahre alte &quot;Bibliothek&quot; zu verwenden und benutz lieber std::thread..<br />
Dann musst du auch nicht irgendwelche unsinnigen C-Casts machen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231251</guid><dc:creator><![CDATA[Nymer]]></dc:creator><pubDate>Mon, 09 Jul 2012 11:15:59 GMT</pubDate></item><item><title><![CDATA[Reply to Multithreading mit Parameter on Mon, 09 Jul 2012 11:50:52 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>und bitte auch ohne das Kopieren des GlobalVariables-Objekts</p>
</blockquote>
<p>Ich würde es kopieren, weil es in dem gezeigten Code nicht global ist (wie der Name ja vermuten lassen könnte), und ich mich nicht darauf verlassen würde, dass es solange lebt wie mein Thread.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2231265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2231265</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Mon, 09 Jul 2012 11:50:52 GMT</pubDate></item></channel></rss>