<?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[Namespace in dll]]></title><description><![CDATA[<p>Hallo,<br />
ich habe eine Frage:<br />
Ist es möglich, dass ich in einer Dll einen namespace deklarieren und ihn in einem Hauptprogramm wieder benutzen kann?<br />
Wenn ja, wie?<br />
Danke!</p>
<p>Jonas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/291124/namespace-in-dll</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 22:26:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/291124.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Aug 2011 06:57:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 06:57:08 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe eine Frage:<br />
Ist es möglich, dass ich in einer Dll einen namespace deklarieren und ihn in einem Hauptprogramm wieder benutzen kann?<br />
Wenn ja, wie?<br />
Danke!</p>
<p>Jonas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104720</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 06:57:08 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 07:43:56 GMT]]></title><description><![CDATA[<p>Ja, ganz normal.</p>
<p>Deine Frage nach der Benutzung verstehe ich nicht. Ganz normal halt. Du linkst gegen die Lib der DLL und inkludierst den Header.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104734</guid><dc:creator><![CDATA[BadWolf]]></dc:creator><pubDate>Thu, 11 Aug 2011 07:43:56 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 07:53:07 GMT]]></title><description><![CDATA[<p>Richtig, das klappt auch.<br />
Aber im Hauptprogamm findet er den Namespace nicht.<br />
Code von der dll.h :</p>
<pre><code>#ifndef __MAIN_H__
#define __MAIN_H__

#include &lt;windows.h&gt;
#include &lt;iostream&gt;

#define DLL __declspec(dllexport)

#ifdef __BORLANDC__ &amp;&amp; __MSDOS__
    #include &lt;conio.h&gt;
#elif __WIN32__ || _MSC_VER
    #define clrscr() system(&quot;cls&quot;)
#else
    #define clrscr() cout &lt;&lt; &quot;clrscr() – Fehler!!\n&quot;
#endif

#include &lt;iostream&gt;

namespace name {
using namespace std;
//Funktionen
DLL void pause();
DLL void cls();
}

#endif // __MAIN_H__
</code></pre>
<p>Code von dll.cpp:</p>
<pre><code>#include &quot;main.h&quot;
namespace name {
DLL void pause() {
system(&quot;PAUSE&quot;);
}
DLL void cls() {
clrscr();
}
}
</code></pre>
<p>Und von Hauptprogramm:</p>
<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

using namespace std;
#define DLL __declspec(dllimport)
using namespace name;

int main(int argc, char *argv[])
{
    pause();
    return EXIT_SUCCESS;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2104737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104737</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 07:53:07 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:00:42 GMT]]></title><description><![CDATA[<p>Stopp.<br />
Welchen Header?<br />
Ich kompiliere die DLL, im Hauptprogramm linke ich die Bibliothek hinzu und habe die Dll im Ordner des Hauptprogramms.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104740</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:00:42 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:09:46 GMT]]></title><description><![CDATA[<p>Ich mach sonst nix mit DLLs. Aber trotzdem ein paar Hinweise von mir:</p>
<p>- Was haben &lt;windows.h&gt; und &lt;iostream&gt; im Header zu suchen? Du verwendest davon ja gar nichts. Das using namespace std; würde ich auch aus dem Header entfernen.</p>
<p>- Du hast scheinbar im Hauptprogramm vergessen, dll.h zu inkludieren. Das mit dem __declspec-Zeug musst Du Dir nochmal von wo anders abgucken (falls Du es überhaupt brauchst). Das Hauptprogramm braucht wahrscheinlich die Deklarationen, die im Header stehen mit DLL=__declspec(dllimport). Dumm nur, dass Du dieses Makro im Header anders definierst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104742</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:09:46 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:08:15 GMT]]></title><description><![CDATA[<p>JonasH schrieb:</p>
<blockquote>
<p>Stopp.<br />
Welchen Header?<br />
Ich kompiliere die DLL, im Hauptprogramm linke ich die Bibliothek hinzu und habe die Dll im Ordner des Hauptprogramms.</p>
</blockquote>
<p>Linken und Kompilieren sind nicht dasselbe. Dem Compiler ist es schnurz, was Du später sonst wie dazu linkst. Er muss die Funktionsdeklarationen sehen. Und die holt man sich typischerweise über Header-Dateien. Dazu sind die ja da.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104743</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:08:15 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:11:13 GMT]]></title><description><![CDATA[<p>Ok,<br />
die nicht benötigten Teile sind raus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Ich glaube ich habe mich etwas falsch ausgedrückt, ich mache aus der dll.cpp und der dll.h eine DLL und das Hauptprogramm sollte mit der Quelldateien der Dll nichts zutun haben, oder habe ich da unrecht? Ich probier das jetzt mal mit der inkludierung der Headerdatei der DLL.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104747</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:11:13 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:13:17 GMT]]></title><description><![CDATA[<p>Klappt.<br />
Allerdings erscheint mir das dann doch etwas umständlich, zusätzlich zu der Bibliothek auch noch den Header der DLL einzubinden. Geht das auch anders?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104749</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:13:17 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:23:24 GMT]]></title><description><![CDATA[<p>Was hat das Ganze denn mit der DLL zu tun? Wenn du eine Funktion, eine Variable oder eine Klasse benutzen möchtest, muss zumindest die Deklaration sichtbar sein. Dabei ist es völlig egal, ob die Implementierung in einer DLL, einer statischen Bibliothek, einer simplen Objektdatei oder sogar in der selben Datei wie der Aufruf steckt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104753</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:30:57 GMT]]></title><description><![CDATA[<p>Ich dachte, dies hätte ich in der DLL getan, und mit der Bibliothek dem Hauptprogramm mitgeteilt; sodass ich dies nicht mehr im Hauptprogramm brauche. Aber das scheint ja nicht zu klappen...</p>
<p>Übrigens: Danke bis hierhin!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104754</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:30:57 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 08:41:18 GMT]]></title><description><![CDATA[<p>Ok, ich probiere es jetzt einmal über eine Klasse, schaut bis jetzt gut aus außer bis auf das:</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;
#define DLL __declspec(dllexport)

#ifdef __BORLANDC__ &amp;&amp; __MSDOS__
    #include &lt;conio.h&gt;
#elif __WIN32__ || _MSC_VER
    #define clrscr() system(&quot;cls&quot;)
#else
    #define clrscr() cout &lt;&lt; &quot;clrscr() – Fehler!!\n&quot;
#endif
//hier gehts los!!!

DLL class JoRa {
      public:
      JoRa(const char* msg) {
                  switch (msg) { //Fehler: switch quantity not an integer 
                              case &quot;pause&quot;:
                              pause();
                              break;
                              case &quot;cls&quot;:
                              cls();
                              break;
                              default: cout &lt;&lt; &quot;Unbekannte Funktion!&quot;;
                  }
      }
      ~JoRa() {}
     //Funktionen

      void pause() {
           cout &lt;&lt; &quot;Bitte Eingabe drücken!&quot;;
           getchar();
      }
      void cls() {
           clrscr();
      }
};
</code></pre>
<p>und wenn ich mit der maus auf msg halte, kommt: UINT msg<br />
das soll doch ein char* sein!?! Ich versteh´s nicht mehr!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104759</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 08:41:18 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 09:14:53 GMT]]></title><description><![CDATA[<p>ok, ich hab es jetzt.<br />
Ich binde einfach den Header ein, das funktioniert prima.</p>
<p>Danke an alle, die geholfen haben!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104774</guid><dc:creator><![CDATA[JonasH]]></dc:creator><pubDate>Thu, 11 Aug 2011 09:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to Namespace in dll on Thu, 11 Aug 2011 09:20:53 GMT]]></title><description><![CDATA[<p>Wo ist denn der Sinn bei der DLL, wenn Du im Header eh inline-Funktionen definierst?</p>
<p>Lass das mit den DLLs doch einfach sein, wenn Du das Konzept der getrennten Übersetzung noch nicht verstanden hast und scheinbar auch noch nichts von der one-definition-rule gehört hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2104776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2104776</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 11 Aug 2011 09:20:53 GMT</pubDate></item></channel></rss>