Author |
Topic |
|
gregholt
6 Posts |
Posted - 02 Jul 2003 : 15:16:52
|
If you generate a simple C++ application using eVC 4.0 for WCE 4.2 against the emulator and try to use standard C++ exception handling techniques (try/catch/throw), you get the following linker error:
unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
From what I can tell in Platform Builder 4.2, you can add "C++ Exception Handling" to your image. I've tried rebuilding the emulator image and working against it but it doesn't resolve this linker error. What am I missing?
Update: If I build a simple "Hello World" app against CE 4.1 with a call to throw in it, it compiles and links. If I change it to build against 4.2, it won't link with the above linker error. This is regardless of whether I specify the /GX option to the compiler. |
Edited by - gregholt on 03 Jul 2003 14:16:28 |
|
ctacke
877 Posts |
Posted - 07 Jul 2003 : 17:14:33
|
Both C++ exceptions and RTTI are available from eVC 4.0, but you must enable both code generation options manually. Consider this code, which uses both:
#include
class Animal { virtual void Speak(){}; };
class Dog : public Animal { void Speak(){}; };
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // code requires C++ Exception handling try { throw L"Exception"; } catch( wchar_t* error ) { MessageBox( NULL, error, L"test", MB_OK ); } // code requires RTTI - run-time type info Animal *animal = new Animal(); Dog *dog = dynamic_cast<Dog *>(animal); return 0; }
This will throw several errors and warnings from a default configuration. To add the proper switches, do the following:
- From the Project menu in eVC 4.0, select Settings...
- In the upper left of the dialog, change the Settings For: dropdown to All Configurations
- In the right pane, choose the C/C++ tab
- From the Category dropdown select Code Generation
- In the Project Options textbox at the bottom of the pane add the following switches
/GR /GX
- Click OK
/GR adds RTTI support /GX adds C++ Exception Handling |
|
|
gregholt
6 Posts |
Posted - 08 Jul 2003 : 08:14:05
|
Chris,
Thanks for the reply. I had /GR and /GX enabled when trying this...forgot to mention that in my original post.
Turns out my image didn't have RTTI in it. After recreating the image with RTTI, everything links now.
It appears that Microsoft included RTTI in the 4.1 image for the emulator, but didn't include it in the 4.2 image. A check of the symbols in coredll.lib proves that the managled version of type_info isn't present in the 4.2 version.
Regards, Greg |
|
|
|
Topic |
|
|
|