compile error about destructor



 DEVELOP > c-Plus-Plus > compile error about destructor

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "George2"
Date: 25 Jan 2008 04:52:15 AM
Object: compile error about destructor
Hello everyone,
When change from __try to try, and __except(GetExceptionCode()) to
catch(...), compile can pass.
Compile error and code are,
1>Compiling...
1>main.cpp
1>d:\visual studio 2008\projects
\test_exception1\test_exception1\main.cpp(30) : warning C4509:
nonstandard extension used: 'main' uses SEH and 'foo1' has destructor
1> d:\visual studio 2008\projects
\test_exception1\test_exception1\main.cpp(28) : see declaration of
'foo1'
1>d:\visual studio 2008\projects
\test_exception1\test_exception1\main.cpp(35) : error C2712: Cannot
use __try in functions that require object unwinding
[Code]
#include <iostream>
#include <excpt.h>
#include <windows.h>
using namespace std;
class Foo
{
public:
Foo()
{
cout << "constructing Foo" << endl;
}
virtual ~Foo()
{
cout << "destrucing Foo" << endl;
}
};
int main()
{
int* address = NULL;
__try{
Foo foo1;
(*address) = 1024;
} __except (GetExceptionCode())
{
cout << "access violation caught" << endl;
}
return 0;
}
[/Code]
regards,
George
.

User: "Ron Natalie"

Title: Re: compile error about destructor 25 Jan 2008 06:11:40 AM
George2 wrote:

1>d:\visual studio 2008\projects
\test_exception1\test_exception1\main.cpp(35) : error C2712: Cannot
use __try in functions that require object unwinding

This has nothing to do with C++ as discussed in this group.
Try a group with MICROSOFT in it's name.
However, that being said, it looks quite obvious from the error that
__try can't handle having any variables that need C++ destruction
semantics to be invoked.
You can map structured exceptions to normal C++ extensions (it takes
a few steps). Again either read the farking manual or go to the
appropraite group.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER