|
I have created a dialog app, which return a debug error meesage that i don't understand. This message is:
Debug error
Program :\CalcRiskPort\Debug\CalcRiskPort.exe
DAMAGE: after Normal block (#81) at 0x00301190
when i pree retry i have this message box:
User breakpoint called from code at 0x1021376f
you could see the following code concerned
void CCalcRiskPortDlg::OnCalcvar()
{
UpdateData(TRUE);
::CoInitialize(NULL);
//LoadTables Table;
//LoadTables Table2(m_dlgSector);
double *pTabVar=new double[(double)pow(2,m_dlgAsset)];
double *pTabMoy=new double[(double)pow(2,m_dlgAsset)];
CString *pTabPortStr=new CString[(long)pow(2,m_dlgAsset)];
CString strValue,strPortOpti,strMaxiSharpe,strMaxiEfficience;
double MiniVar,MaxiSharpe,MaxiEfficience;
int Rang;
double *pMiniVar=new double[2];
//double *pMiniRatio=new double[2];
double *pMaxiRatioSharpe=new double[2];
double *pMaxiRatioEfficience=new double[2];
int *pTabBinPort=new int[m_dlgAsset];
int *pTabNumPort=new int[m_dlgAsset];
int k,i;
try
{
LoadTables Table(1,m_dlgSector,1,m_dlgSector);
_ConnectionPtr pConnection=NULL;
CString strTemp;
strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\Vol&CorrelDB.mdb;");
_bstr_t strCnn(strTemp);
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
pConnection->Open(strCnn,"","",adConnectUnspecified);
Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation");
Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité");
Table.pYield=Table.LoadYield(m_dlgSector,Table.pYield,"Ratio");
i=0;
for(k=0;k<=m_dlgAsset-1;k++)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
}
*pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset);
*pTabMoy=Table.CalcMoy(pTabNumPort,m_dlgAsset);
Table.pRatioSharpe[0]=(*pTabMoy)/(*pTabVar);
Table.pRatioEfficience[0]=((*pTabMoy+i)-m_dlgRate0)/(*pTabVar);
*pTabPortStr=Table.AgregIntToStr(pTabNumPort,m_dlgAsset);
for(i=1;i<=pow(2,m_dlgAsset)-1;i++)
{
k=m_dlgAsset-1;
while(*(pTabBinPort+k)==1)
{
*(pTabBinPort+k)=0;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
if(k!=0)
k--;
}
*(pTabBinPort+k)=1;
Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort);
*(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset);
*(pTabMoy+i)=Table.CalcMoy(pTabNumPort,m_dlgAsset);
Table.pRatioEfficience[i]=(*(pTabMoy+i))/(*(pTabVar+i));
Table.pRatioSharpe[i]=((*(pTabMoy+i))-m_dlgRate0)/(*(pTabVar+i));
*(pTabPortStr+i)=Table.AgregIntToStr(pTabNumPort,m_dlgAsset);
}
pMiniVar=Table.CalcMin(pTabVar,pMiniVar,(long)pow(2,m_dlgAsset));
pMaxiRatioSharpe=Table.CalcMax(Table.pRatioSharpe,pMaxiRatioSharpe,m_dlgAsset);
pMaxiRatioEfficience=Table.CalcMax(Table.pRatioEfficience,pMaxiRatioEfficience,m_dlgAsset);
MiniVar=pMiniVar[0];
MaxiSharpe=pMaxiRatioSharpe[0];
MaxiEfficience=pMaxiRatioEfficience[0];
Rang=(int)pMiniVar[1];
m_dlgValue=pTabVar[Rang];
m_dlgValue *=100;
m_dlgPortOpti=*(pTabPortStr+Rang);
strPortOpti=m_dlgPortOpti;
m_dlgSharpe=MaxiSharpe;
m_dlgEfficience=MaxiEfficience;
strMaxiSharpe.Format("%.5f",m_dlgSharpe);
strMaxiEfficience.Format("%.5f",m_dlgEfficience);
strValue.Format("%.5f",m_dlgValue);
CEdit* PEdit=(CEdit*)GetDlgItem(IDC_VALUE);
PEdit->SetWindowText(strValue);
CEdit* SEdit=(CEdit*)GetDlgItem(IDC_OPTI_PORT);
SEdit->SetWindowText(strPortOpti);
CEdit* ShEdit=(CEdit*)GetDlgItem(IDC_OPTI_SHARPE);
ShEdit->SetWindowText(strMaxiSharpe);
CEdit* EffEdit=(CEdit*)GetDlgItem(IDC_OPTI_EFFICIENCE);
EffEdit->SetWindowText(strMaxiEfficience);
delete []pMiniVar;
delete []pMaxiRatioSharpe;
delete []pMaxiRatioEfficience;
delete []pTabBinPort;
delete []pTabNumPort;
delete []pTabVar;
delete []pTabMoy;
pConnection->Close();
}
catch(_com_error &e)
{
AfxMessageBox("a pas bon");
}
::CoUninitialize();
// TODO: Add your control notification handler code here
}
so i hope that someone could help me to solve my problem
thanks in advance for your answers
gerald
|
|
|
|
|
The error is most likely due to some out-of-bounds error: your code is trying to write beyond the limits of some of your arrays.
When the assertion pops up, press "Retry" to get the debugger to the point where the error showed and use the "Call stack" window to determine which buffer is being overrun. This and a little research of your write operations will hopefully locate the error.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
you were right, in fact i declare a wrong memory space for only one pointer that have to be deleted by the class destructor, but there was a problem as when i put value to this pointer, i did it in a for loop, in which i would like to put more that ten times memory spacxe than i have allocated.
thanks a lot
gerald
|
|
|
|
|
Hi, need a hand !
(This message is lot but really easy to read )
I have a project with 2 classes. First is a normal class :
class __declspec(dllexport) Demo
{
public:
int valeur;
Demo(int x=0);
int getValue();
void setValue(int x);
};
My second class is a template :
template <class t="">
class __declspec(dllexport) Element
{
public:
T element;
public:
Element(T);
~Element();
void setElement(T);
T getElement();
};
I have an other project using those two classes. Here's the MAIN function :
#include <iostream.h>
#include "..\test_DLL\test.h"
void main()
{
Demo obj;
obj.setValue(15);
cout << obj.getValue() << endl;
Demo obj2(21);
cout << obj2.getValue() << endl;
Element<int> e1(15);
e1.setElement(15);
cout << "Valeur : " << e1.getElement() << endl;
}
Simple, right ? Here's the errors :
test.obj : error LNK2001: unresolved external symbol "public: __thiscall Element<int>::~Element<int>(void)" (??1?$Element@H@@QAE@XZ)
test.obj : error LNK2001: unresolved external symbol "public: int __thiscall Element<int>::getElement(void)" (?getElement@?$Element@H@@QAEHXZ)
test.obj : error LNK2001: unresolved external symbol "public: void __thiscall Element<int>::setElement(int)" (?setElement@?$Element@H@@QAEXH@Z)
test.obj : error LNK2001: unresolved external symbol "public: __thiscall Element<int>::Element<int>(int)" (??0?$Element@H@@QAE@H@Z)
Debug/test.exe : fatal error LNK1120: 4 unresolved externals
It seems that it cannot find the definition of those functions. It is not the path of my *.LIB of anything else since I don`t have any errors about the DEMO class. If I put the use of the class ELEMENT in commentaries, it is working fine. It seems to be related to the TEMPLATE.
Can we use templates in a DLL ? May be not after all... I`ve search the web and didn`t find any answers. Thk for taking the time to read this ! Hope somebody will help me on that one...
|
|
|
|
|
Hello Frederic.
The good news: You can use templates exported thru a DLL.
The bad news: You must know in advance for which particular types the template class is going to be used.
The procedure is as follows (I'll use your template class instantiated for int s): In some .cpp in your DLL, explicitly instantiate the template like this:
template class__declspec(dllexport) Element<int>; This produces the actual code for Element<int> . Now, in the header file add this:
extern template class __declspec(dllimport) Element<int>; which tells the linker that Element<int> is instantiated somewhere else (extern ) and will be linked at run-time from a DLL (__declspec(dllimport) ). I hope I haven't made any syntax error. Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Everything is working fine. But, I have 3 friends functions in this class :
friend ostream& operator << (ostream&, ListeChaineSimple&);
friend ListeChaineSimple& operator << (ListeChaineSimple&, const T&);
friend ListeChaineSimple& operator >> (ListeChaineSimple&, const T&);
And, compiling the EXE gives me those error :
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator>>(class ListeChaineSimple<int> &,int const &)" (??5@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class ListeChaineSimple<int> &)" (??6@YAAAVostream@@AAV0@AAV?$ListeChaineSimple@H@@@Z)
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator<<(class ListeChaineSimple<int> &,int const &)" (??6@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
is it the same thing ? I`ve tried this in the DLL project :
template class __declspec(dllexport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple<int>&);
template class __declspec(dllexport) ListeChaineSimple<int>& __cdecl operator<< (ListeChaineSimple<int>&, int const&);
template class __declspec(dllexport) ListeChaineSimple<int>& __cdecl operator>> (ListeChaineSimple<int>&, int const&);
It compiles fine but the EXE will not work. Anyone ?
|
|
|
|
|
Is ListeChaineSimple a template class? If it is not, then add this to your header:
__declspec(dllimport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple&); and this to your .cpp :
__declspec(dllexport) ostream& __cdecl operator<< (ostream&, ListeChaineSimple&)
{
...
} (and similarly for the other operators.) In this case, thos global friend s can be treated as regular functions you export the usual way.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually, it is a template class. Here`s the code in the *.H :
template <class t=""> class __declspec(dllexport) ListeChaineSimple
{
public:
ElementSimple<t> * head;
ListeChaineSimple(T =0);
virtual ~ListeChaineSimple();
friend __declspec(dllexport) ostream& operator << (ostream&, ListeChaineSimple&);
friend __declspec(dllexport) ListeChaineSimple& operator << (ListeChaineSimple&, const T&);
friend __declspec(dllexport) ListeChaineSimple& operator >> (ListeChaineSimple&, const T&);
};
I followed your advice :
typedef ListeChaineSimple<int> LCS_int;
template __declspec(dllexport) ostream& operator<< (ostream&, LCS_int&);
template __declspec(dllexport) LCS_int& operator<< (LCS_int&, const int&);
template __declspec(dllexport) LCS_int& operator>> (LCS_int&, const int&);
Compilation is good. But running it from my application with the DLL, I'm having this error :
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator>>(class ListeChaineSimple<int> &,int const &)" (??5@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class ListeChaineSimple<int> &)" (??6@YAAAVostream@@AAV0@AAV?$ListeChaineSimple@H@@@Z)
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator<<(class ListeChaineSimple<int> &,int const &)" (??6@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
Debug/TP3_EXE.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
I've made a LOT of tests... Everything is fine but this case, there`s something I`m missing. Do you know what exactly ? Thanks in avanced...
|
|
|
|
|
Seems some '<' s are missing (your template definitions lack the parameters list). Please try reposting your message with the checkbox "Display this message as-is (no HTML)" set on. Thanx.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi again,
You`re right. I didn`t notice it. Here`s the code :
In the DLL Project :
A) DEMO.H
template <class T>
class __declspec(dllexport) ListeChaineSimple
{
public:
ElementSimple<T> * head;
ListeChaineSimple(T =0);
virtual ~ListeChaineSimple();
friend __declspec(dllexport) ostream& operator << (ostream&, ListeChaineSimple&);
friend __declspec(dllexport) ListeChaineSimple& operator << (ListeChaineSimple&, const T&);
friend __declspec(dllexport) ListeChaineSimple& operator >> (ListeChaineSimple&, const T&);
};
B) DEMO.CPP
template <class T>
ostream& operator << (ostream& out, ListeChaineSimple<T>& liste)
{
...
}
template <class T>
ListeChaineSimple<T>& operator << (ListeChaineSimple<T>& liste, const T& x)
{
...
}
template <class T>
ListeChaineSimple<T>& operator >> (ListeChaineSimple<T>& liste, const T& x)
{
...
}
AND
typedef ListeChaineSimple<int> LCS_int;
template __declspec(dllexport) ostream& operator<< (ostream&, LCS_int&);
template __declspec(dllexport) LCS_int& operator<< (LCS_int&, const int&);
template __declspec(dllexport) LCS_int& operator>> (LCS_int&, const int&);
In the application Project :
TEST.CPP :
#include "..\demo_dll\demo.h"
void main()
{
...
ListeChaineSimple<int> liste(4);
liste << 6;
liste << 8;
liste << 10;
liste << 15;
cout << liste;
liste >> 6;
liste >> 4;
liste >> 2;
cout << liste;
...
}
The errors :
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator>>(class ListeChaineSimple<int> &,int const &)" (??5@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class ListeChaineSimple<int> &)" (??6@YAAAVostream@@AAV0@AAV?$ListeChaineSimple@H@@@Z)
error LNK2001: unresolved external symbol "class ListeChaineSimple<int> & __cdecl operator<<(class ListeChaineSimple<int> &,int const &)" (??6@YAAAV?$ListeChaineSimple@H@@AAV0@ABH@Z)
Debug/TP3_EXE.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
I know it should be something stupid but I can`t figure it out... Thk in advanced !
|
|
|
|
|
Please check these two things:- The header
demo.h must read __declspec(dllexport) when building the DLL and __declspec(dllimport) when using it in the program test.cpp . I guess you already knew that and didn't bother to specify in your post. The standard technique to have this done is with some macro hackery.
- Provided the first point is not the issue, then maybe you're having problems explicitly instantiating the functions. Try forcing an implicit instantiation:
void __declspec(dllexport) dummy()
{
typedef ListeChaineSimple<int> LCS_int;
LCS_int liste:
int n;
ofstream ofs("quelque chose");
ofs<<liste;
liste<<n;
liste>>n;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
can anybody tell me if there's a way to insert a bmp as a background for a dialog, i can make a pic control and stretch it to fit the dialog and insert the bmp on it, but i was wondering if there's another way, thanks in advance....
|
|
|
|
|
Handle WM_ERASEBKGND
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
You can also handle WM_CTLCOLOR
Ex: You have a bitmap resource as IDB_BITMAP1
1. In OnInitDialog(), use the code:
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
m_brush.CreatePatternBrush(&bm);
bm.DeleteObject();
with m_brush is member variable of Your dialog class
2. Handle WM_CTLCOLOR (not return hbr)
pDC->SetBkMode(TRANSPARENT);
return m_brush;
//return hbr;
3. Destroy m_brush in DestroyWindow()
Good luck
Hung Son
|
|
|
|
|
I've run out of ideas trying to track this problem down.
I've created a template class and have a private member variable called m_MSGList.
typedef CTypedPtrList<CPtrList, MSG*> tplMSG;
template <class T> class CD : public CWinThread
{
.
.
.
private:
tplMSG m_MSGList;
}
--------------------------------
When this line of code executes:
m_MSGList.AddTail(pmsg);
I get:
ASSERT_VALID fails with illegal vtable pointer.
--------------------------------
help.
|
|
|
|
|
Found the problem. Right above m_MSGList i declared an array. in the constructor i overwrote the array.
I knew something like that was going on. It just took a coffe break and a fresh start to figure it out.
|
|
|
|
|
Hi
I have an application containing server and client.It is older version and I converted into new version.But one .lib file is missing.The link error I got is
LINK : fatal error LNK1104: cannot open file "D:\pathi\RTDesk\RTdesk\RTdesk\RemoteDesktopViewer_server\debug\zipdbg.lib"
How can I fix this problem and execute the server and client?
Please help me.
Regards
Pathi
Pathi
|
|
|
|
|
The only solution is the obvious one, add the library that is missing.
|
|
|
|
|
But I dont have that library.I got this application from my
friend who got it from net.When I opened it asked for whether to convert it to new version of developer studio and I pressed "ok".When I compiled no problems but getting the error while building.Do I need to change any project seettings or what are the options to remove the error?
Thank you.
Pathi
|
|
|
|
|
Try contacting the author.
|
|
|
|
|
Hi,
I´m trying to show one ActiveX that contains an IPicture that shows an Enhanced metafile...
This don´t works if I have it embedded in Ms Word, any idea why is this ? Does IPicture Render don´t work, when it´s in design mode ? ( DT_METAFILE), I have had even problems with the normal mode
Please help, Thanks !
Braulio
|
|
|
|
|
I've just upgraded from VC++5 on one system to VC++6 on a different system.
Moving a 3-project workspace was painless except that the IDE won't now
remember what files were open & automatically re-open them when I next
restart VisualStudio or re-open the workspace.
I've checked Tools/Options/Workspace tab, and have both "reload last
workspace at startup" and "reload documents when opening workspace" checked,
but only the first of these has any effect.
Any ideas?
|
|
|
|
|
try delete/move all not necessary binaries
(means all opt ncb and similars, except sources, dsp, dsw)
and try again
t!
|
|
|
|
|
I am searching for a way to do a one-to-many data broadcast on internet, but since most routers have digestion problems with UDP broadcast i am looking for alternative. I have encountered multicast, but i dont know how covered is internet with multicast enabled routers...
Does someone know for any alternative? Central server is not an option.
|
|
|
|
|
Hi,
I a beginner VC++ programmer,
What are the step to folow to add a custom control to a dialog ?
thanks
|
|
|
|
|