B
bellerophon
I am having a serious trouble with my pointers in a programm that uses
dll and was hoping that somebody in this group could help me:
I export my DLL classes with declspec(dllexport) and link against them
using the lib-file. I do not use anything but stuff included in the C++
standard libraries (like iostream) so far.
In my calling application I first do
class __declspec(dllimport) Image {
public:
Image();
....
};
and afterwards I do
double * values = new double[9];
double values[0] = 0.0;
....
double values[8] = 0.0;
cout << "DEBUG: values is at address " << values << endl;
Image im();
cout << "DEBUG: deleting at memory address " << values << endl;
delete [] values;
The empty image constructor does nothing, not even initializing the
member variables with standard values. I tried to resimulate the
ever-reoccuring problem under a minimal environment and an in my
opinion an empty member constructor is such.
Now I fail to delete values. The output of the program is:
DEBUG: values is at address 003814C0
DEBUG: deleting at memory address 00381400
Obviously I am either overwriting the pointer to the array or I having
some other heap problem - which is really driving me crazy, since I
can't find the reason for it.
When I am calling a static (exported) function such as
Image:
rintHelloWorld(); the problem doesn't occur.
If I am initializing values from stack (double values[9]); values[0] is
overwritten after the DLL method call...
Can anybody tell me, what I seem to be missing here?
Thanks in advance
dll and was hoping that somebody in this group could help me:
I export my DLL classes with declspec(dllexport) and link against them
using the lib-file. I do not use anything but stuff included in the C++
standard libraries (like iostream) so far.
In my calling application I first do
class __declspec(dllimport) Image {
public:
Image();
....
};
and afterwards I do
double * values = new double[9];
double values[0] = 0.0;
....
double values[8] = 0.0;
cout << "DEBUG: values is at address " << values << endl;
Image im();
cout << "DEBUG: deleting at memory address " << values << endl;
delete [] values;
The empty image constructor does nothing, not even initializing the
member variables with standard values. I tried to resimulate the
ever-reoccuring problem under a minimal environment and an in my
opinion an empty member constructor is such.
Now I fail to delete values. The output of the program is:
DEBUG: values is at address 003814C0
DEBUG: deleting at memory address 00381400
Obviously I am either overwriting the pointer to the array or I having
some other heap problem - which is really driving me crazy, since I
can't find the reason for it.
When I am calling a static (exported) function such as
Image:
If I am initializing values from stack (double values[9]); values[0] is
overwritten after the DLL method call...
Can anybody tell me, what I seem to be missing here?
Thanks in advance