Click here to Skip to main content
15,918,108 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WMI,IPAddress,SubnetMask setting! Doesn't work. Pin
Tcpip200512-Sep-05 1:39
Tcpip200512-Sep-05 1:39 
QuestionVolume Control through program.... Pin
ashwath200512-Sep-05 1:17
ashwath200512-Sep-05 1:17 
AnswerRe: Volume Control through program.... Pin
David Crow12-Sep-05 3:10
David Crow12-Sep-05 3:10 
QuestionRe: Volume Control through program.... Pin
ashwath200512-Sep-05 4:29
ashwath200512-Sep-05 4:29 
AnswerRe: Volume Control through program.... Pin
David Crow12-Sep-05 4:39
David Crow12-Sep-05 4:39 
GeneralRe: Volume Control through program.... Pin
ashwath200512-Sep-05 18:33
ashwath200512-Sep-05 18:33 
GeneralRe: Volume Control through program.... Pin
David Crow19-Sep-05 7:25
David Crow19-Sep-05 7:25 
Questionpassing reference to vector in dll function Pin
Anonymous12-Sep-05 1:15
Anonymous12-Sep-05 1:15 
hi,
i'm passing a vector of doubles by reference to a function, which assigns some values to the vector. if i compile this function into a dll and link the library i get a run time debug assertion failure:

code to make library:
#include <vector>
using namespace std;
extern "C" __declspec(dllexport)void MyDblFunc(vector<double> &Dbl)
{
	for(int i=0; i<10; i++)
	{
		Dbl.push_back(1.1*i);
	}
	return;
}


code to use the library function:
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;

extern "C" __declspec(dllexport) void MyDblFunc(vector<double> &Dbl);

void main()
{
         vector<double> MyDbl;
	MyDblFunc(MyDbl);
	int N= (int)MyDbl.size();
	cout<<N<<'\n';
	for(int i=0; i<N; i++)
	{
		cout<<MyDbl[i]<<'\n';
	}

	return;
}


which writes the expected output and then produces Debug Assertion Failures: _CrtIsValidHeapPointer(pUserData) and _pFirstBlock==pHead.

However, if i put the function body code in the source after main (ie not using a dll) then i get no such error. Why does this happen? and what can i do about it? i want to put as many of my subroutines as possible into dlls as they are common to many programs, and also i want to use vectors so that i can dynamically allocate memory at run time. Is there a difference between passing a vector by reference or passing a pointer to the vector... i have been told that the reference can get reallocated when the vector resizes which could cause a problem in the calling routine... any advice at all would be great.

Thanks for your helpBig Grin | :-D
AnswerRe: passing reference to vector in dll function Pin
ab8lam12-Sep-05 1:49
ab8lam12-Sep-05 1:49 
AnswerRe: passing reference to vector in dll function Pin
Nemanja Trifunovic12-Sep-05 2:17
Nemanja Trifunovic12-Sep-05 2:17 
QuestionGraphics.MeasureString word wrap problem Pin
Kramer_198212-Sep-05 1:13
Kramer_198212-Sep-05 1:13 
QuestionOutlined Font in Direct3D ? Pin
Danoo12-Sep-05 1:10
Danoo12-Sep-05 1:10 
QuestionSystem Menu in MFC -Plz Help Pin
parims12-Sep-05 0:45
parims12-Sep-05 0:45 
AnswerRe: System Menu in MFC -Plz Help Pin
toxcct12-Sep-05 0:50
toxcct12-Sep-05 0:50 
Questionwhat does the MapViewOfFile do exactly?? Pin
Anonymous12-Sep-05 0:42
Anonymous12-Sep-05 0:42 
AnswerRe: what does the MapViewOfFile do exactly?? Pin
Niklas L12-Sep-05 3:06
Niklas L12-Sep-05 3:06 
GeneralRe: what does the MapViewOfFile do exactly?? Pin
namaskaaram12-Sep-05 4:02
namaskaaram12-Sep-05 4:02 
GeneralRe: what does the MapViewOfFile do exactly?? Pin
Niklas L12-Sep-05 4:24
Niklas L12-Sep-05 4:24 
GeneralRe: what does the MapViewOfFile do exactly?? Pin
Chintoo72312-Sep-05 6:01
Chintoo72312-Sep-05 6:01 
GeneralRe: what does the MapViewOfFile do exactly?? Pin
namaskaaram12-Sep-05 17:11
namaskaaram12-Sep-05 17:11 
QuestionCreate child process Pin
whofmans12-Sep-05 0:29
whofmans12-Sep-05 0:29 
AnswerRe: Create child process Pin
David Crow12-Sep-05 3:13
David Crow12-Sep-05 3:13 
QuestionProblems with .NET double data type Pin
sirtimid12-Sep-05 0:11
sirtimid12-Sep-05 0:11 
AnswerRe: Problems with .NET double data type Pin
toxcct12-Sep-05 0:18
toxcct12-Sep-05 0:18 
GeneralRe: Problems with .NET double data type Pin
sirtimid12-Sep-05 0:42
sirtimid12-Sep-05 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.