|
yes so check it against t1
dereference first the pointer you receive and then compare it to typeid(ccar)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Papa wrote:
dereference first the pointer you receive and then compare it to typeid(ccar)
what do you mean by this?
sorry, english isn't my first language
|
|
|
|
|
cvehicle *vtemp=(list->Getvehicle());
if (typeid(*vtemp)==typeid(ccar)))
return vtemp;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
it gives me an error: (runtime error, it builds alright)
unhandled exception
|
|
|
|
|
"If the expression is dereferencing a pointer, and that pointer’s value is zero, typeid throws a bad_typeid exception. If the pointer does not point to a valid object, a __non_rtti_object exception is thrown."
Do you have a NULL pointer?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
no, *vtemp isn't null
it gives me this warning
warning C4541: 'typeid' used on polymorphic type 'class ccar' with /GR-; unpredictable behavior may result
|
|
|
|
|
typeid depends on RTTI being turned on. RTTI is part of the language standard but C++ turns it off by default. Change your project settings to enable RTTI and you will get rid of the compile-time warning and the run-time exception.
|
|
|
|
|
that did it!!!!!!!!!!!!!1
thanks!!
|
|
|
|
|
you deference a pointer when you don't get the address it contains but when you get what is at the pointed address.
<font style="color:blue;">char</font>* pc = (<font style="color:blue;">char</font>*)malloc(<font style="color:blue;">sizeof</font>(<font style="color:blue;">char</font>)); <font style="color:green;">
*pc = 'a'; <font style="color:green;">
pc : simple pointer (cointaining an address)
*pc : dereferenced pointer (value at the pointed address)
TOXCCT >>> GEII power
|
|
|
|
|
Hi all,
Is there a way to respond to an external function call raised by another process without having to modify the callees's code?
Thanks.
|
|
|
|
|
the "raising" process must send its PID however you won't be able to know who sent you such message.
TOXCCT >>> GEII power
|
|
|
|
|
Does anyone see anything wrong with this code? It's called from an OnPaint handler that calls EnumChildWindows (this is the callback proc). Everytime it runs the program tells me that it hit a breakpoint, that I didn't set and, which is in assembly code, and then it terminates. The error code it terminates with is 0x80000003 which is "One or more argumets are invalid". Any ideas?
BOOL CALLBACK CInputDlg::RedrawErrors (HWND hWnd, LPARAM lParam)
{
CInputDlg* dlg = reinterpret_cast<CInputDlg*>(lParam);
TCHAR buff[32];
CWnd verify;
::GetClassName (hWnd, buff, sizeof (buff) - 1);
if (_stricmp (buff, "edit") != 0)
return TRUE;
verify.Attach (hWnd);
int id = verify.GetDlgCtrlID ();
if (id == IDC_TICKET) {
CVerifyData data (dlg->GetDlgItem (IDC_TICKET), Ticket, dlg);
if (data.GetErrorFlag () == CVerifyData::InvalidData)
data.ShowError ();
}
else if (id == IDC_CIRCUIT) {
CVerifyData data (dlg->GetDlgItem (IDC_TICKET), Circuit, dlg);
if (data.GetErrorFlag () == CVerifyData::InvalidData)
data.ShowError ();
}
else if (id >= IDC_CREATED && id <= IDC_DISPATCHED) {
CVerifyData data (dlg->GetDlgItem (id), Date, dlg);
if (data.GetErrorFlag () == CVerifyData::InvalidData)
data.ShowError ();
}
else if (id >= IDC_TICKET && id <= IDC_NOTES) {
CVerifyData data (dlg->GetDlgItem (id), Blank, dlg);
if (data.GetErrorFlag () == CVerifyData::InvalidData)
data.ShowError ();
}
return TRUE;
}
- Aaron
|
|
|
|
|
Calling EnumWindows to validate / verify is not normal and definately should not be called from OnPaint.
Are you trying to validate / verify data while it is being input?
There are many handlers that can be used for the individual controls. If you handle EN_CHANGE then as each control it altered then you can perform your validation / verification.
Ant.
|
|
|
|
|
That's not what I'm trying to do. The controls are validated elsewhere, the problem I'm encountering is that if a control contains invalid information a red * is put beside it. Now if the dialog is covered by another window or minmized, etc the red *'s disappear because they are not redrawn. The code I showed above doesn't actually validate anything, it just checks to see if the control has invalid or valid data.
- Aaron
|
|
|
|
|
Have you tried commenting out a few lines at a time until the "error" goes away? If I remember, the WM_PAINT message is a very frequent message so doing extraneous stuff in its handler is not usually a good idea.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
In this case, 0x80000003 means STATUS_BREAKPOINT , the exception that Windows raises when it hits an int 3 instruction (on x86). The debugger normally intercepts this exception and stops the program's execution, showing you where it stopped.
If you're getting an unexpected breakpoint, you may have jumped to an incorrect address, or you may have corrupted your heap, or caused one of your other DLLs to ASSERT. The Windows heap code will cause a breakpoint exception if it detects that the program is running under a debugger and has corrupted the heap.
It might be useful to get the OS debugging symbols to determine whether you've landed in a system function. If you're using Visual Studio .NET (2002 or 2003), you can use Microsoft's Symbol Server to download debugging symbols on demand - this is the preferred option. See http://support.microsoft.com/default.aspx?scid=kb;en-us;319037[^] for more information.
Visual Studio 6 can't use the symbol server, so you can try the Debugging Symbols Packages[^], which are a complete set of symbols for a particular OS. However, these are only updated with every service pack; you may well find that the debugger won't load some of them because they don't match the installed binaries (due to security patches and other hotfixes). You could also try using the Windows Debugging Tools[^], although these are a lot harder to use.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for the reply Mike. Well the program is breaking on an int 3 instruction. I don't really know how I could have jumped to an incorrect address or corrupted the heap with the code I have though. I downloaded the symbols, but I'm not sure if there's something I have to do to use them. I ran the program again and it broke on assembly code again. The VC debugger shows that it broke in NTDLL. Any ideas? Thanks for the help. I don't know that much about hardcore debugging so I'm kind of at a loss. Thanks again Mike.
I was just checking some other things. After the program terminates there's a line in the output box that says "Second Chance Assertion Faild" and then gives the file. What's a "second chance assertion"? Thanks.
- Aaron
|
|
|
|
|
I forgot to mention that you need to set _NT_SYMBOL_PATH to tell the debugger where to find the OS symbols. It still may not do any good because
At a guess, I think you've ended up at ntdll!DbgBreakPoint , an internal function in NTDLL - a piece of the OS code has explicitly called the break-point function. I still think this may be heap related.
I've found an article http://www.codeproject.com/debug/cdbntsd3.asp[^] which may be helpful.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks again for the help Mike. Read the link and it was informative, but out of my depth. I'll take a harder look at my code though to see if it looks like I'm corrupting the heap anywhere. Thanks again for all the help.
- Aaron
|
|
|
|
|
Hi,
can someone please give me an example of how to
translate a domain name eg. www.codeproject.com
into its IP address.
i have this working for network machine names but
not for domain names.
preferably into CString or unsigned long format.
Thanks
|
|
|
|
|
You could try looking at gethostbyname.
- Aaron
|
|
|
|
|
Aaron
i cannot get that to work..
GetHostAddress("http://www.coderproject.com");
unsigned long DialogClass::GetHostAddress(LPCSTR host)
{
struct hostent *phe;
char *p;
phe = gethostbyname(host);
p = *phe->h_addr_list; // Crash here
return *((unsigned long*)p);
}
any ideas ?
|
|
|
|
|
Try changing:
p = *phe->h_addr_list; to
p = *phe->h_addr;
- Aaron
|
|
|
|
|
Didn't compile it so it may have type-o's...
struct hostent *hp;
unsigned int addr;
struct sockaddr_in name_ip;
if(inet_addr(strDns) == INADDR_NONE)
hp = gethostbyname(strDns);
else
{
addr = inet_addr(strDns);
hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
}
if(hp == NULL)
{
}
name_ip.sin_addr.s_addr = *((unsigned long*)hp->h_addr);
name_ip.sin_family = AF_INET;
name_ip.sin_port = htons(iPort);
CString strSocketIP = inet_ntoa(name_ip.sin_addr);
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Rob,
thanks for that
but
in flow of execution
strDns = "www.codeproject.com";
hp = gethostbyname(strDns); executes fine
name_ip.sin_addr.s_addr = *((unsigned long*)hp->h_addr); // crash occurs
name_ip.sin_family = AF_INET;
name_ip.sin_port = htons(iPort);
any ideas?
|
|
|
|