<?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[Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das?]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe folgende funktion in meiner dll:</p>
<pre><code class="language-cpp">#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------
__declspec(dllexport)void FindAreas(TStringList* VDAList,std::vector&lt;int&gt;* startStopPositions,
                                std::vector&lt;std::pair&lt;int,int&gt; &gt;*startStopVector) throw (String)

{
   int start, stop;
   int searchLen = VDAList-&gt;Count;
   int areacounter;

   for(unsigned int i = 0;i &lt; searchLen; ++i)
      {
        if(VDAList-&gt;Strings[i].SubString(0,3)==&quot;512&quot;)
           {
            areacounter++;
            startStopPositions.push_back(i);  //Anfang von neuem 512 Block
           }
      }

   if(areacounter!=startStopPositions.size()) //wenn meher &quot;startpositioen als areale
      {
        throw String(&quot;Synchronisationsfehler&quot;);
      }

   for(unsigned int i = 0;i &lt; areacounter; ++i)
      {
        start = startStopPositions.at(i);

        //sind wir am letzten startpunkt angekommen?
        //wenn ja ist das ende der datei die letzte zeile
        //sonst ist das ende des einen blockes der anfang des nächsten -1
        if(i+1 &gt;= areacounter)
           stop = searchLen;
        else
           stop = startStopPositions.at(i+1);     //hier ende ist der anfang des neuen

        //ist i nicht wirklich das ende der datei, muss die stopposition um
        //1 nach vorn gelegt werden, da sonst der anfang der nächsten area
        //das ende des vorhergehenden wäre
        if(i!=areacounter-1)
         --stop;

         //nun füllen wir den vector mit den anfang und endwertden der bereiche
         startStopVector.push_back(std::make_pair(start,stop));
      }
}
</code></pre>
<p>da diese funktionen diese vectoren direkt verändert, habe ich sie als zeiger übergeben....damit änderungen auch im aufrufenden programm stattfinden!</p>
<p>dieses sieht so aus:</p>
<p>.h</p>
<pre><code class="language-cpp">#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;Dialogs.hpp&gt;
#include &lt;Menus.hpp&gt;
#include &lt;vector&gt;
#include &lt;utility&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
        TOpenDialog *OpenDialog1;
        TMainMenu *MainMenu1;
        TMenuItem *Datei1;
        TMenuItem *ffnen1;
        TMemo *Memo1;
        void __fastcall ffnen1Click(TObject *Sender);
private:	// Anwender-Deklarationen
public:		// Anwender-Deklarationen
        __fastcall TForm1(TComponent* Owner);
        std::vector&lt;int&gt; stStopPositions;
        std::vector&lt;std::pair&lt;int,int&gt; &gt; stStopVector;
        TStringList* VDALIST;
};

__declspec(dllimport)void FindAreas(TStringList* VDAList,std::vector&lt;int&gt;* startStopPositions,
                                std::vector&lt;std::pair&lt;int,int&gt; &gt;* startStopVector);
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>.cpp</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ffnen1Click(TObject *Sender)
{
  if(OpenDialog1-&gt;Execute())
   {
      Memo1-&gt;Lines-&gt;Clear();
      delete VDALIST;
      VDALIST = 0;
      VDALIST = new TStringList();
      stStopVector.clear();
      stStopPositions.clear();
      FindAreas(VDALIST,&amp;stStopPositions,&amp;stStopVector);
      for(int i = 0;i &lt; stStopVector.size(); ++i)
         {
           Memo1-&gt;Lines-&gt;Add(&quot;Bereiche: &quot; + String(stStopPositions.size()));
           Memo1-&gt;Lines-&gt;Add(&quot;Start Bereich #&quot; + String(i) + String (stStopVector.at(i).first)
                                + &quot; Stop Bereich #&quot; + String(i) + String(stStopVector.at(i).second));
         }
   }
}
//---------------------------------------------
</code></pre>
<p>jedoch bekomme ich folgenden fehelr:</p>
<pre><code>[Linker Fehler] Unresolved external 'FindAreas(Classes::TStringList *, _STL::vector&lt;int, _STL::allocator&lt;int&gt; &gt; *, _STL::vector&lt;_STL::pair&lt;int, int&gt;, _STL::allocator&lt;_STL::pair&lt;int, int&gt; &gt; &gt; *)' referenced from D:\VDA_REMAKE\FUNKTION_IN_DLL\UNIT1.OBJ
</code></pre>
<p>wie übergbe ich diese vectoren richtig??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/160694/funktion-in-dll-die-vectoren-und-stirnglists-als-parameter-hat-wie-geht-das</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 06:16:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/160694.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Sep 2006 13:46:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Thu, 28 Sep 2006 13:46:53 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe folgende funktion in meiner dll:</p>
<pre><code class="language-cpp">#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------
__declspec(dllexport)void FindAreas(TStringList* VDAList,std::vector&lt;int&gt;* startStopPositions,
                                std::vector&lt;std::pair&lt;int,int&gt; &gt;*startStopVector) throw (String)

{
   int start, stop;
   int searchLen = VDAList-&gt;Count;
   int areacounter;

   for(unsigned int i = 0;i &lt; searchLen; ++i)
      {
        if(VDAList-&gt;Strings[i].SubString(0,3)==&quot;512&quot;)
           {
            areacounter++;
            startStopPositions.push_back(i);  //Anfang von neuem 512 Block
           }
      }

   if(areacounter!=startStopPositions.size()) //wenn meher &quot;startpositioen als areale
      {
        throw String(&quot;Synchronisationsfehler&quot;);
      }

   for(unsigned int i = 0;i &lt; areacounter; ++i)
      {
        start = startStopPositions.at(i);

        //sind wir am letzten startpunkt angekommen?
        //wenn ja ist das ende der datei die letzte zeile
        //sonst ist das ende des einen blockes der anfang des nächsten -1
        if(i+1 &gt;= areacounter)
           stop = searchLen;
        else
           stop = startStopPositions.at(i+1);     //hier ende ist der anfang des neuen

        //ist i nicht wirklich das ende der datei, muss die stopposition um
        //1 nach vorn gelegt werden, da sonst der anfang der nächsten area
        //das ende des vorhergehenden wäre
        if(i!=areacounter-1)
         --stop;

         //nun füllen wir den vector mit den anfang und endwertden der bereiche
         startStopVector.push_back(std::make_pair(start,stop));
      }
}
</code></pre>
<p>da diese funktionen diese vectoren direkt verändert, habe ich sie als zeiger übergeben....damit änderungen auch im aufrufenden programm stattfinden!</p>
<p>dieses sieht so aus:</p>
<p>.h</p>
<pre><code class="language-cpp">#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include &lt;Classes.hpp&gt;
#include &lt;Controls.hpp&gt;
#include &lt;StdCtrls.hpp&gt;
#include &lt;Forms.hpp&gt;
#include &lt;Dialogs.hpp&gt;
#include &lt;Menus.hpp&gt;
#include &lt;vector&gt;
#include &lt;utility&gt;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// Von der IDE verwaltete Komponenten
        TOpenDialog *OpenDialog1;
        TMainMenu *MainMenu1;
        TMenuItem *Datei1;
        TMenuItem *ffnen1;
        TMemo *Memo1;
        void __fastcall ffnen1Click(TObject *Sender);
private:	// Anwender-Deklarationen
public:		// Anwender-Deklarationen
        __fastcall TForm1(TComponent* Owner);
        std::vector&lt;int&gt; stStopPositions;
        std::vector&lt;std::pair&lt;int,int&gt; &gt; stStopVector;
        TStringList* VDALIST;
};

__declspec(dllimport)void FindAreas(TStringList* VDAList,std::vector&lt;int&gt;* startStopPositions,
                                std::vector&lt;std::pair&lt;int,int&gt; &gt;* startStopVector);
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
</code></pre>
<p>.cpp</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ffnen1Click(TObject *Sender)
{
  if(OpenDialog1-&gt;Execute())
   {
      Memo1-&gt;Lines-&gt;Clear();
      delete VDALIST;
      VDALIST = 0;
      VDALIST = new TStringList();
      stStopVector.clear();
      stStopPositions.clear();
      FindAreas(VDALIST,&amp;stStopPositions,&amp;stStopVector);
      for(int i = 0;i &lt; stStopVector.size(); ++i)
         {
           Memo1-&gt;Lines-&gt;Add(&quot;Bereiche: &quot; + String(stStopPositions.size()));
           Memo1-&gt;Lines-&gt;Add(&quot;Start Bereich #&quot; + String(i) + String (stStopVector.at(i).first)
                                + &quot; Stop Bereich #&quot; + String(i) + String(stStopVector.at(i).second));
         }
   }
}
//---------------------------------------------
</code></pre>
<p>jedoch bekomme ich folgenden fehelr:</p>
<pre><code>[Linker Fehler] Unresolved external 'FindAreas(Classes::TStringList *, _STL::vector&lt;int, _STL::allocator&lt;int&gt; &gt; *, _STL::vector&lt;_STL::pair&lt;int, int&gt;, _STL::allocator&lt;_STL::pair&lt;int, int&gt; &gt; &gt; *)' referenced from D:\VDA_REMAKE\FUNKTION_IN_DLL\UNIT1.OBJ
</code></pre>
<p>wie übergbe ich diese vectoren richtig??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145967</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145967</guid><dc:creator><![CDATA[sdsd]]></dc:creator><pubDate>Thu, 28 Sep 2006 13:46:53 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Thu, 28 Sep 2006 13:53:12 GMT]]></title><description><![CDATA[<p>habe es aus spaß mal auf referenzen umgestellt, nun kann ich es linken, bekomme aber bei der benutzung der funktion, eine Externe Exception!</p>
<p>wieso bzw.. wie kann ich erkennen was da schief geht?</p>
<p>oder mache ich grundsätzlich was falsch??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145976</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145976</guid><dc:creator><![CDATA[sdsd]]></dc:creator><pubDate>Thu, 28 Sep 2006 13:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Thu, 28 Sep 2006 13:54:08 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Laß doch mal die Exceptionspezifikation beim Export weg. Vielleicht hilft das ja. Hast du die dll statische eingebunden und auch die Importbibliothekt zum Projekt hinzugefügt?<br />
Bei Übergabe von VCL-Objekten und insbesonder bei STL-Klassen mußt du aufpassen, dass du deine Dlls und die Projekte die sie verwenden mit der gleichen BCBVersion kompiliert wurden. BCB5, BCB6 und BDS verwenden jeweils unterschiedliche STL-Bibliotheken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1145977</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1145977</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 28 Sep 2006 13:54:08 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Thu, 28 Sep 2006 14:48:59 GMT]]></title><description><![CDATA[<p>also ist statisch und die lib ist drin!</p>
<p>mit dem exception versuch ich morgen!</p>
<p>hoffentlich klappt das!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1146029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146029</guid><dc:creator><![CDATA[sdsds]]></dc:creator><pubDate>Thu, 28 Sep 2006 14:48:59 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Fri, 29 Sep 2006 07:05:36 GMT]]></title><description><![CDATA[<p>also ich habe die excpetion-spezialisierung weggenommen!</p>
<p>geht jetzt (linken und so)</p>
<p>aber beim benutzen bekomm ich eine externe exception!</p>
<p>woran könnte das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1146312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146312</guid><dc:creator><![CDATA[sdsd]]></dc:creator><pubDate>Fri, 29 Sep 2006 07:05:36 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Fri, 29 Sep 2006 07:16:16 GMT]]></title><description><![CDATA[<p>whabe mal geschaut wo ungefähr der fehler auftritt, habe das im code mit &quot;------&gt;&gt;&gt;&gt;&gt;&gt;&quot; markiert</p>
<pre><code class="language-cpp">__declspec(dllexport)void FindAreas(TStringList* VDAList,std::vector&lt;int&gt;* startStopPositions,
                                std::vector&lt;std::pair&lt;int,int&gt; &gt;* startStopVector)

{
   int start, stop;
   int searchLen = VDAList-&gt;Count;
   int areacounter;

   for(unsigned int i = 0;i &lt; searchLen; ++i)
      {
        if(VDAList-&gt;Strings[i].SubString(0,3)==&quot;512&quot;)
           {
            areacounter++;
            startStopPositions-&gt;push_back(i);  //Anfang von neuem 512 Block
           }
      }

   if(areacounter!=startStopPositions-&gt;size()) //wenn meher &quot;startpositioen als areale
      {
        //throw String(&quot;Synchronisationsfehler&quot;);                   //---------&gt;&gt;&gt;&gt;&gt;&gt;er geht bis hier hin, und bringt dann die Exception (auch wenn es auskommentiert ist)
//davor ist er noch in die __vector.h gesprungen, sonst nirgends hin
      }                                             */

   for(unsigned int i = 0;i &lt; areacounter; ++i)
      {
        start = startStopPositions-&gt;at(i);

        //sind wir am letzten startpunkt angekommen?
        //wenn ja ist das ende der datei die letzte zeile
        //sonst ist das ende des einen blockes der anfang des nächsten -1
        if(i+1 &gt;= areacounter)
           stop = searchLen;
        else
           stop = startStopPositions-&gt;at(i+1);     //hier ende ist der anfang des neuen

        //ist i nicht wirklich das ende der datei, muss die stopposition um
        //1 nach vorn gelegt werden, da sonst der anfang der nächsten area
        //das ende des vorhergehenden wäre
        if(i!=areacounter-1)
         --stop;

         //nun füllen wir den vector mit den anfang und endwertden der bereiche
         startStopVector-&gt;push_back(std::make_pair(start,stop));
      }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1146316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146316</guid><dc:creator><![CDATA[ssds]]></dc:creator><pubDate>Fri, 29 Sep 2006 07:16:16 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Fri, 29 Sep 2006 07:20:23 GMT]]></title><description><![CDATA[<p>ok, hab mal den gesamten funktionsrumpf auskommentiert, selbst da tritt fehler auf!</p>
<p>hm...weis nicht mehr so richtig weiter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1146321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146321</guid><dc:creator><![CDATA[sds]]></dc:creator><pubDate>Fri, 29 Sep 2006 07:20:23 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion in DLL die vectoren und StirngLists als Parameter hat, wie geht das? on Fri, 29 Sep 2006 11:18:20 GMT]]></title><description><![CDATA[<p>hm...habe das mal alles in kleine funktionen aufgeteilt, da scheint es zu funktionieren, auch mit den stl und vcl komponenten!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1146482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1146482</guid><dc:creator><![CDATA[sadsds]]></dc:creator><pubDate>Fri, 29 Sep 2006 11:18:20 GMT</pubDate></item></channel></rss>