Solved

DLL STL Vector

Posted on 2001-07-10
10
455 Views
Last Modified: 2013-12-14
I have my main header for my DLL, I export 1 function:

const CText __stdcall Parse (const std::wstring & wstrText, const in iLanguage);

My class CText contain vector, I got a problem.

How can I pass by parameter a vector from DLL to exe file?
0
Comment
Question by:fortineric
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:fortineric
ID: 6269696
...
0
 
LVL 3

Accepted Solution

by:
elcapitan earned 25 total points
ID: 6269765
find this article in MSDN:
HOWTO: Exporting STL Components Inside & Outside of a Class

--EC--
0
 
LVL 22

Expert Comment

by:nietod
ID: 6269798
>>  Exporting STL Components Inside & Outside of a Class
is that the right topic?   What is the article's Q ID number?


There should be nothing speciial for you to do.  i..e it should work automatically if you use the DLL version of the run-time library (RTL).  You need to use the DLL RTL whenever you share dynmically allocated memory between a DLL and an EXE where one of them alocates the memory and the other deletes it.  if you pass objects that manage memory (like strings, vectors, lists etc) between an EXE and DLL then you have this situation. i.e. code in one might allcoate and code in the other might free.  so you must use the DLL RTL.  Note that both the EXE and the DLL must use the DLL RTL.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:elcapitan
ID: 6269799
And the link:
http:// support.microsoft.com / support / kb / articles / Q168 / 9 / 58.ASP

Check also this link:
http:// support.microsoft.com / support / kb / articles / Q172 / 3 / 96.ASP

--EC--
0
 
LVL 22

Expert Comment

by:nietod
ID: 6269826
Those links don't work.  Even when the spaces are removed they still don't work.

The answer is very simple, are you sure these articles are right for the probkem?
0
 
LVL 3

Expert Comment

by:elcapitan
ID: 6269882
>>Those links don't work
They worked fine for me. Look for Q168958 and Q172396. If you have copy of MSDN on your local disk, you can find it there as well

>>are you sure these articles are right for the probkem?
here is the summery of the first one from MSDN:

"SUMMARY
This article demonstrates how to:

Export an instantiation of a Standard Template Library (STL) class.


Export a class that contains a data member that is an STL object.


Note that you may not export a generalized template. The template must be instantiated; that is, all of the template parameters must be supplied and must be completely defined types at the point of instantiation. For instance "stack<int>;" instantiates the STL stack class. The instantiation forces all members of class stack<int> to be generated.

Also note that some STL containers (map, set, queue, list, deque) cannot be exported. Please refer to the More Information section to follow for a detailed explanation. "

--EC--
0
 
LVL 22

Expert Comment

by:nietod
ID: 6270623
>> Export an instantiation of a Standard Template Library (STL) class.
that isn't what this is asking for.

>> Export a class that contains a data member that is an STL object.
That isn't what this is asking for.
0
 
LVL 1

Expert Comment

by:ccaprar
ID: 6272357
From my previous STL experience I think that if the class CText contains a std::vector from STL, the vector template has to be instantiated first. The rules for doing that can be found in the following MSDN article: Q168958 (http://support.microsoft.com/support/kb/articles/Q168/9/58.ASP)

Both nietod and elcapitain are right, you should link to the same RTL version (debug or release) and you should instantiate the template.

Another useful article is Q172396 (http://support.microsoft.com/support/kb/articles/Q172/3/96.ASP) as elcapitain said earlier here. Though, it describes the problems when exporting a template object or a class with a member template.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6825689
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "nietod, elcapitan" comment(s) as suggested by ccaprar as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6875323
Per recommendation comment force/accepted by

Netminder
Community Support Moderator
Experts Exchange

nietod: points for you at http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20278061
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question