Archive for November, 2009

Upgrade to VC20xx: Problems with Exception Handling

Friday, November 13th, 2009

If you upgrade from VC6 to VC2008, then your project will automatically converted to the new format.
As a side-effect, it will also default to the new exception handling which breaks compatibilty to VC6.

Therefor this post ;)

In VC6, by default the “/EHa” exception model ist activ.
In VC200x and later, by default, the “/EHsc” exception model is active. This means that if you did not explicit specify the “/EHa” model, you will now automatically use the “/EHsc” model, which only catches C++ exceptions!

For example, the following code will work as expected and will crash in VS2008:

#include <stdio.h>
#include <tchar.h>
 
int _tmain()
{
  try
  {
    printf("Now doing an AV...\n");
    char *c = NULL;
    strcpy(c, "Hello");
    printf(c);
  }
  catch(...)
  {
    printf("Catched....");
  }
}

So be aware, that if you rely on asynchonus exceptions, you need to switch the expetion model in the C/C++ project settings under “Code generation | Enabled C++ Exceptions: Yes with SEH Exceptions (/EHa)

StackWalker moved to CodePlex

Sunday, November 1st, 2009

If you have ever published an article on CodeProject, you will see that maintanance an ariticle is practicale impossible. In the last several years, I improved the source-code of my “StackWalker” article outside of codeproject, but this also leads to confusion…

So today I moved at least the source code to codeplex:
http://stackwalker.codeplex.com/