在使用EVC时,有时要catch一些异常,但是EVC现在还不支持此功能,但是microstft已经出了一个lib来支持他。下面是选自microstft的文章。
http://support.microsoft.com/kb/830482/en-us
The Run-time Type Information library for the Pocket PC 2003 SDK is available
Article ID | : | 830482 |
Last Review | : | November 2, 2004 |
Revision | : | 1.0 |
SUMMARY
To provide developers with full Microsoft eMbedded Visual C++ Exception Handling and dynamic cast support on Microsoft Windows Powered Pocket PC 2003 devices, Microsoft is distributing the Run-time Type Information (RTTI) library for the Pocket PC 2003 SDK.
The following file is available for download from the Microsoft Download Center:
Download the RITTI.exe package now.
(http://download.microsoft.com/download/1/9/4/194f4a97-755f-4e66-b386-48c39f56d379/ritti.exe)
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
The RTTI.exe download includes the library files (.lib) and program database files (.pdb) for the "ArmV4" and "emulator" builds.
To use the RTTI library in a Pocket PC 2003 project, follow these steps:
The following file is available for download from the Microsoft Download Center:
![Download Download](http://support.microsoft.com/library/images/support/kbgraphics/public/EN-US/Download.gif)
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591
(http://support.microsoft.com/kb/119591/) How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
The RTTI.exe download includes the library files (.lib) and program database files (.pdb) for the "ArmV4" and "emulator" builds.
To use the RTTI library in a Pocket PC 2003 project, follow these steps:
1. | Copy the Ccrtrtti.lib and Ccrtrtti.pdb files from the ArmV4 and Emulator folders in the download to the folders that are named ArmV4 and Emulator inside the /Lib folder of the Pocket PC 2003 SDK. Note By default, these directories are found in the C:/Program Files/Windows CE Tools/wce420/POCKET PC 2003/Lib/ArmV4OrEmulator folder on desktop computers that have the Pocket PC 2003 SDK installed. | ||||||
2. | For all project configurations that you intend to target, include Ccrtrtti.lib in Project Settings of eMbedded Visual C++ 4.0, follow these steps:
| ||||||
3. | Follow these steps:
|
MORE INFORMATION
C++ Exception Handling code that uses "throw" constructs, "catch" constructs, or both with data types requires RTTI support to identify the type of exception. Without the RTTI library, typed C++ Exception Handling code causes a linker error message that is similar to the following error message:
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@) For example, without the RTTI library, the following code causes the previous linker error:
The same logic applies to "throw" constructs that involve any data. For example, the statement
Without the RTTI library, the only exception handling construct that works is the kind that involves no data types. For example, the following code links without the RTTI library without causing an error message:
The following is a known problem with eMbedded Visual C++ 4.0 Service Pack 2 (SP2) when you use this RTTI library. Single-stepping through the code over the closing brace after the last logical statement in the try/catch block in an application would cause the following events:
At the point of the crash or when the application stops responding (at the end of the
try/catch block), the eMbedded Visual C++ IDE will report an access violation with the following error message:
First Chance exception Microsoft is aware of this problem and is working toward fixing this problem in a future release.
The workaround to this problem is to set a breakpoint at the first statement after the end of the try/catch block and then to let the application run through the end of the try/catch block and continue debugging at the breakpoint. Do not single-step through the code after you have reached the last logical statement in the try/catch block.
The RTTI library files also provide support for dynamic casts. For example, without the RTTI library, eMbedded Visual C++ 4.0 will report a linker error with the following code:
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
error LNK2019: unresolved external symbol ___RTDynamicCast referenced in function "void __cdecl Test(void)" (?Test@@YAXXZ) The dynamic cast code builds successfully with the inclusion of the RTTI libraries in the project.
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
try
{
// The code here can raise exceptions.
}
catch(int i)
{
// Optional exception handling logic goes here.
}
The linker returns the error because it cannot find the RTTI library that is required for type-identification of exceptions of type int. The same logic applies to "throw" constructs that involve any data. For example, the statement
throw 1;
requires RTTI to determine the matching "catch" block that would handle exceptions with int values.Without the RTTI library, the only exception handling construct that works is the kind that involves no data types. For example, the following code links without the RTTI library without causing an error message:
try
{
// The code here can raise exceptions.
}
catch(...)
{
// Generic exception handling logic goes here.
}
With the RTTI library files, all the C++ Exception Handling constructs (typed and un-typed) that are in this section of this article should generate correct executables. You do not have to have extra DLLs because the RTTI logic is already in the DLLs that are on the Pocket PC 2003 device and emulator.The following is a known problem with eMbedded Visual C++ 4.0 Service Pack 2 (SP2) when you use this RTTI library. Single-stepping through the code over the closing brace after the last logical statement in the try/catch block in an application would cause the following events:
• | A crash occurs in the executable of the application on the Pocket PC 2003 emulator. |
• | The application stops responding (hang) on the Pocket PC 2003 device. |
First Chance exception
The workaround to this problem is to set a breakpoint at the first statement after the end of the try/catch block and then to let the application run through the end of the try/catch block and continue debugging at the breakpoint. Do not single-step through the code after you have reached the last logical statement in the try/catch block.
The RTTI library files also provide support for dynamic casts. For example, without the RTTI library, eMbedded Visual C++ 4.0 will report a linker error with the following code:
struct A
{
int a;
A() : a(1) {}
virtual ~A() {} // All the rest of destructors will be virtual.
};
void Test()
{
A a;
A* a4 = dynamic_cast<A>(&a);
}
The linker error looks similar to the following:
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
error LNK2019: unresolved external symbol ___RTDynamicCast referenced in function "void __cdecl Test(void)" (?Test@@YAXXZ)
APPLIES TO
• | Microsoft Windows Mobile 2003 software for Pocket PCs Standard Edition |
• | Microsoft eMbedded Visual C++ 4.0 |
Keywords: | kbinfo KB830482 |