<?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[C++ DLL in C Programm verlinken??]]></title><description><![CDATA[<p>Mal ne blöde Frage... (oder auch nich!?:)</p>
<p>kann ich bspw. ein C++ Programm in eine DLL packen, und dies dann in einem C Programm verwenden??</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/177082/c-dll-in-c-programm-verlinken</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 18:30:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/177082.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Mar 2007 07:22:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:22:17 GMT]]></title><description><![CDATA[<p>Mal ne blöde Frage... (oder auch nich!?:)</p>
<p>kann ich bspw. ein C++ Programm in eine DLL packen, und dies dann in einem C Programm verwenden??</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254308</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254308</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:22:17 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:37:36 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Du packst natürlich kein Programm in eine DLL, sondern Funktionen/Klassen.<br />
Wenn du für die DLL ein C-Interface einbaust kannst du auch diese DLL von C aus benutzen. Innerhalb der DLL kannst du dann wieder mit Klassen etc arbeiten.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254314</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:37:36 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:43:06 GMT]]></title><description><![CDATA[<p>ja das problem ist , das ich meinentwegen 50 Klassen in einem Modul haben.. diese Modul will ich all DLL exprotieren und ich einem C Programm verwenden..</p>
<p>Die problematik liegt darin, das ich ja in C keine Klassen habe, und ich weis nich genau , ob ich aus einem C++ Code generierte DLL in einem C Programm verwende.......</p>
<p>Müsste gehen oder? kenn mich nich so aus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254319</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:43:06 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:52:26 GMT]]></title><description><![CDATA[<p>Da kommst Du bestimmt selbst drauf:<br />
Welchen Header bindest Du in Dein C-Programm ein ? Was soll da drin stehen ? Was soll der C-Compiler damit machen ? ... <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>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254327</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:52:26 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:47:53 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Gar nicht. C kann nicht mit C++ Klassen umgehen. Du must dafür ein C-Interface in die DLL stecken um die C++ Klassen zu wrappen.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254328</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:47:53 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 07:53:54 GMT]]></title><description><![CDATA[<p>mach mal ein Beispiel.. akari.. sorry.. wenn ich so Anfängermäsig frage</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254331</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Wed, 28 Mar 2007 07:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 08:08:12 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Nehmen wir mal an du hast so eine Klasse</p>
<pre><code class="language-cpp">class IntBuf
{
public :
  IntBug(int zahl) : m_zahl(zahl) {};
  int GetZahl() {return m_zahl;};
private :
  int m_zahl;
};
</code></pre>
<p>Um diese Klasse aus einer DLL heraus für C verfügbar zu machen must du dafür ein C-Interface schreiben und in die DLL packen. Dazu betrachtest du die Instanzen der Klasse an sich als Speicherblöcke, die per Handles verwaltet werden</p>
<pre><code class="language-cpp">typedef void* c_IntBuf;

c_IntBuf CreateIntBuf(int zahl)
{
  return reinterpret_cast&lt;c_intBuf&gt;(new IntBug(zahl));
}
int GetZahl(c_IntBuf intbuf)
{
  return reinterpret_cast&lt;IntBuf*&gt;(intbuf)-&gt;GetZahl();
}
void FreeIntBuf(c_IntBuf intbuf)
{
  delete reinterpret_cast&lt;IntBuf*&gt;(intbuf);
}
</code></pre>
<p>Diese neuen Funktionen können nun von der DLL in C-Manier exportiert werden (extern C...) und von jeder anderen DLL-fähigen Entwicklungsumgebung verwendet werden, auch C</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254341</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 28 Mar 2007 08:08:12 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 08:09:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">/* DLL */
extern &quot;C&quot; int meineCFunktionInCpp() {
  // mach was C++ mässiges
  Klasse k;
  k.Irgendwas( new Klasse2 );
  k.Irgendwas( new Klasse3 );
  k.Aufraeumen();
}

/* C-Programm */
int main(void) {
  meineCFunktionInCpp();
}
</code></pre>
<p>EDIT:<br />
Ok, etwas abstrakter als akaris, und ausserdem viel zu spät...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254343</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 28 Mar 2007 08:09:38 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 08:10:11 GMT]]></title><description><![CDATA[<p>[edit: zu spät]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254344</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Wed, 28 Mar 2007 08:10:11 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 08:13:45 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10648">@LordJaxom</a> : Ich habe eben gezeigt wie Klassen direkt gewrappt werden, du degegen wie zusammenhängende Funktionalität. Hat beides seine Vor- und Nachteile. <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>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254350</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 28 Mar 2007 08:13:45 GMT</pubDate></item><item><title><![CDATA[Reply to C++ DLL in C Programm verlinken?? on Wed, 28 Mar 2007 08:32:45 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>man darf aber nicht vergessen, dass man eben mit C-Mitteln nicht alles abbilden kann, was C++ kann. Bei Vererbung, templates, overloading, accesspecifier, .... ist da nicht viel oder nur mit einer Menge Fingerbrechen zu machen.<br />
... und exceptions muss man sowieso immer alle fangen und in C-Fehlerhandling umwandeln.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1254377</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1254377</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Wed, 28 Mar 2007 08:32:45 GMT</pubDate></item></channel></rss>