<?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[Typconversation von C Funktion scheitert]]></title><description><![CDATA[<p>Ich habe folgenden Code aus einer vorgebenen C Datei, den ich mit C++ kompilieren möchte:</p>
<p>vorgegeben:</p>
<pre><code>int (__stdcall *MMC_COM_open_Ptr)(int PortNumber, int baudrate);
MMC_COM_open_Ptr = (void*) GetProcAddress(DLLHandle, &quot;MMC_COM_open&quot;);
</code></pre>
<p>ich bekomme die Fehlermeldung:</p>
<pre><code>1&gt;e:\daten\dev\cpp\hibiscus\positioningcontrol\positioningcontrol\positioningcontrol\pi_c862mercury.cpp(31) : error C2440: '=': 'void *' kann nicht in 'int (__stdcall *)(int,int)' konvertiert werden
1&gt;        Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung
</code></pre>
<p>Was mache ich damit jetzt?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/199742/typconversation-von-c-funktion-scheitert</link><generator>RSS for Node</generator><lastBuildDate>Sat, 03 Oct 2026 21:19:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/199742.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Dec 2007 17:00:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typconversation von C Funktion scheitert on Thu, 06 Dec 2007 17:00:44 GMT]]></title><description><![CDATA[<p>Ich habe folgenden Code aus einer vorgebenen C Datei, den ich mit C++ kompilieren möchte:</p>
<p>vorgegeben:</p>
<pre><code>int (__stdcall *MMC_COM_open_Ptr)(int PortNumber, int baudrate);
MMC_COM_open_Ptr = (void*) GetProcAddress(DLLHandle, &quot;MMC_COM_open&quot;);
</code></pre>
<p>ich bekomme die Fehlermeldung:</p>
<pre><code>1&gt;e:\daten\dev\cpp\hibiscus\positioningcontrol\positioningcontrol\positioningcontrol\pi_c862mercury.cpp(31) : error C2440: '=': 'void *' kann nicht in 'int (__stdcall *)(int,int)' konvertiert werden
1&gt;        Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung
</code></pre>
<p>Was mache ich damit jetzt?</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416012</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Thu, 06 Dec 2007 17:00:44 GMT</pubDate></item><item><title><![CDATA[Reply to Typconversation von C Funktion scheitert on Thu, 06 Dec 2007 17:12:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">typedef int (__stdcall *MMC_COM_open_Ptr_t)(int PortNumber, int baudrate);
MMC_COM_open_Ptr_t MMC_COM_open_Ptr;
MMC_COM_open_Ptr = (MMC_COM_open_Ptr_t) GetProcAddress(DLLHandle, &quot;MMC_COM_open&quot;);
</code></pre>
<p>Syntax ohne Gewähr, sollte aber passen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416027</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416027</guid><dc:creator><![CDATA[betman]]></dc:creator><pubDate>Thu, 06 Dec 2007 17:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to Typconversation von C Funktion scheitert on Thu, 06 Dec 2007 18:17:43 GMT]]></title><description><![CDATA[<p>Wenn de schon C++ hast, nimm einen reinterpret_cast ^^</p>
<pre><code class="language-cpp">typedef int(__stdcall*fn_mmc_com_open)(int, int);

::HINSTANCE hDllMMCCom(::LoadLibrary(TEXT(&quot;mmc.dll&quot;));
if (hDllMMCCom == NULL) throw std::runtime_error(&quot;could not load required programm part!&quot;);

fn_mmc_com_open mmc_com_open = reinterpret_cast&lt;fn_mmc_com_open&gt;(::GetProcAddress(hDllMMCCom, TEXT(&quot;MMC_COM_open&quot;));
if (mmc_com_open == NULL) throw std::runtime_error(&quot;invalid dll \&quot;mmc.dll\&quot;&quot;);
mmc_com_open(10, 100);

::FreeLibrary(hDllMMCCom);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1416056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416056</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 06 Dec 2007 18:17:43 GMT</pubDate></item><item><title><![CDATA[Reply to Typconversation von C Funktion scheitert on Fri, 07 Dec 2007 14:55:58 GMT]]></title><description><![CDATA[<p>Welchen Vorteil hat den ein</p>
<pre><code>::HINSTANCE
</code></pre>
<p>gegenüber einem</p>
<pre><code>HINSTANCE
</code></pre>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416576</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Fri, 07 Dec 2007 14:55:58 GMT</pubDate></item><item><title><![CDATA[Reply to Typconversation von C Funktion scheitert on Fri, 07 Dec 2007 15:06:56 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<pre><code class="language-cpp">typedef int(__stdcall*fn_mmc_com_open)(int, int);

fn_mmc_com_open mmc_com_open = reinterpret_cast&lt;fn_mmc_com_open&gt;(::GetProcAddress(hDllMMCCom, TEXT(&quot;MMC_COM_open&quot;));
</code></pre>
</blockquote>
<p>bislang weise ich die funktion wie folgt zu</p>
<pre><code>int __stdcall MMC_COM_open(int PortNumber, int baudrate) { return (*MMC_COM_open_Ptr)(PortNumber, baudrate);}
</code></pre>
<p>Wie passt das zu deiner Definition?<br />
Geht auch ein</p>
<pre><code>typedef int(__stdcall*fn_mmc_com_open)(int PortNumber, int baudrate);
fn_mmc_com_open mmc_com_open
</code></pre>
<p>in der .h Datei und folgendes in der .cpp Datei?</p>
<pre><code>mmc_com_open = reinterpret_cast&lt;fn_mmc_com_open&gt;(::GetProcAddress(hDllMMCCom, TEXT(&quot;MMC_COM_open&quot;));
</code></pre>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1416586</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1416586</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Fri, 07 Dec 2007 15:06:56 GMT</pubDate></item></channel></rss>