在EVC是加上cty...catch...支持。

4 篇文章 0 订阅

在使用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 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:
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:
a. In eMbedded Visual C++ 4.0, click the Link tab in the Project Settings dialog box.
b. Type Ccrtrtti.lib in the Object/Library modules box.
c. Click OK.
3.Follow these steps:
a. In the Project Settings dialog box, click the C/C++ tab.
b. Add the /GX switch in the Project Options list. You need this switch to compile exception handling code in the project.

Note If the project uses dynamic cast, add the /GR switch.

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:
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.
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:
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)
The dynamic cast code builds successfully with the inclusion of the RTTI libraries in the project.

APPLIES TO
Microsoft Windows Mobile 2003 software for Pocket PCs Standard Edition
Microsoft eMbedded Visual C++ 4.0
Keywords: 
kbinfo KB830482
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值