Created
September 5, 2015 19:01
-
-
Save superbaddude/b52e60f2e8dee0868af2 to your computer and use it in GitHub Desktop.
windows using cgo and c++ with try/catch/throw logic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdexcept> | |
extern "C" | |
{ | |
void throw_and_catch_exception() | |
{ | |
try | |
{ | |
throw std::runtime_error("test throw error"); | |
} | |
catch (...) | |
{ | |
// ignore this exception | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testcgos | |
/* | |
void throw_and_catch_exception(); | |
*/ | |
import "C" | |
func Callthrow_and_catch_exception() { | |
C.throw_and_catch_exception() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testcgos | |
import "testing" | |
func Test_Callthrow_and_catch_exception(t *testing.T) { | |
Callthrow_and_catch_exception() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment