<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Minor irritation with void pointers</title>
		<link>http://www.allegro.cc/forums/view/556700</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 02 Jan 2006 12:57:23 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>using Dev C++ here... coding in C.</p><p>I&#39;m using install_param_int here, and it accepts a void pointer as an arguement. If I send an int pointer as the arguement, it works but I&#39;ve got install_param_int in quite a few places. This creates a hell alot of Warning signals from the compiler and it floods the compiler error screen so much that I find it hard to tell my real problems sometimes.</p><p>So i just created a void *pointer, pointed it at the address of the int, and used that as the arguement. Now I got a different warning &quot;assignment discards qualifiers from pointer target type&quot;. </p><p>Can anyone tell me how to disable specific warnings for Dev C++ (or MingW... i duno which is the culprit)? Its really bugging me.</p><p>Thanks<br />=Han=
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ju-Han Soon)</author>
		<pubDate>Sat, 31 Dec 2005 21:11:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Typecasting your int to a void pointer should work. (void*)&amp;my_int? but that doesn&#39;t seem right.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve Terry)</author>
		<pubDate>Sat, 31 Dec 2005 21:28:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Compile the project in C, not C++.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Sat, 31 Dec 2005 21:47:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Steve Terry said:</div><div class="quote"><p>
Typecasting your int to a void pointer should work. (void*)&amp;my_int? but that doesn&#39;t seem right.
</p></div></div><p>

Why doesn&#39;t it seem right? It&#39;s the only way if you&#39;re using C++!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Simon Parzer)</author>
		<pubDate>Sat, 31 Dec 2005 21:53:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> myint <span class="k3">=</span> <span class="n">42</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/install_param_int" target="_blank"><span class="a">install_param_int</span></a><span class="k2">(</span>..., <span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span><span class="k2">)</span><span class="k3">&amp;</span>myint<span class="k2">)</span><span class="k2">;</span>
...
<span class="k1">void</span> mything<span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span>param<span class="k2">)</span>
<span class="k2">{</span>
   <span class="k1">int</span> theint <span class="k3">=</span> <span class="k2">(</span><span class="k1">int</span> <span class="k3">*</span><span class="k2">)</span>param<span class="k2">;</span>
<span class="c">//   theint should == 42</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Sat, 31 Dec 2005 22:20:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks! I just needed to know about (void*)&amp;my_int thats all... and it worked! no more warnings. </p><p>=Han=
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ju-Han Soon)</author>
		<pubDate>Mon, 02 Jan 2006 06:45:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Assuming myint won&#39;t leave scope while the timer is running (eg. a local variable). If it does, your program will crash when it tries to access invalid memory. For example:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">int</span> mynum<span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/install_timer" target="_blank"><span class="a">install_timer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  intall_param_int<span class="k2">(</span>myfunc, <span class="n">10</span>, <span class="k2">(</span><span class="k1">void</span><span class="k3">*</span><span class="k2">)</span><span class="k3">&amp;</span>mynum<span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/install_keyboard" target="_blank"><span class="a">install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/install_mouse" target="_blank"><span class="a">install_mouse</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/set_gfx_mode" target="_blank"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT, <span class="n">640</span>, <span class="n">480</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>

  <a href="http://www.allegro.cc/manual/rest" target="_blank"><span class="a">rest</span></a><span class="k2">(</span><span class="n">1000</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>Here, main will return and invalidate mynum, which the timer can still try to use before Allegro&#39;s exit handlers properly stop and close the timer functions. As well, changing mynum in main will change the value in the timer (and vice versa).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 02 Jan 2006 12:57:23 +0000</pubDate>
	</item>
</rss>
