Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g++ -O0 -shared -o unwind.dll unwind.cxx
- // OR
- // cl.exe /nologo /Od /MD /EHa /LD /Fe:unwind.dll unwind.cxx
- #include <iostream>
- #include <exception>
- #include <windows.h>
- class Foo
- {
- public:
- ~Foo()
- {
- std::cerr << "Exiting C++" << std::endl;
- }
- };
- typedef void(*func)(void*);
- void throws_fn()
- {
- std::cerr << "C++ throws exception" << std::endl;
- throw std::exception();
- }
- extern "C" __declspec(dllexport) void catches_fn(func fn)
- {
- Foo foo;
- try
- {
- fn(throws_fn);
- }
- catch(std::exception& e)
- {
- std::cerr << "C++ catches exception" << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement