All Forums
 Microsoft Windows CE
 eVC Application Development
 C++ Exceptions - Updated
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

gregholt

6 Posts

Posted - 02 Jul 2003 :  15:16:52  Show Profile  Email Poster
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  Show Profile  Email Poster
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:
  1. From the Project menu in eVC 4.0, select Settings...
  2. In the upper left of the dialog, change the Settings For: dropdown to All Configurations
  3. In the right pane, choose the C/C++ tab
  4. From the Category dropdown select Code Generation
  5. In the Project Options textbox at the bottom of the pane add the following switches
    /GR /GX
  6. Click OK


/GR adds RTTI support
/GX adds C++ Exception Handling
Go to Top of Page

gregholt

6 Posts

Posted - 08 Jul 2003 :  08:14:05  Show Profile  Email Poster
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
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.03 seconds. Snitz Forums 2000