Skip to content

Instantly share code, notes, and snippets.

@superbaddude
Created September 5, 2015 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superbaddude/b52e60f2e8dee0868af2 to your computer and use it in GitHub Desktop.
Save superbaddude/b52e60f2e8dee0868af2 to your computer and use it in GitHub Desktop.
windows using cgo and c++ with try/catch/throw logic
#include <stdexcept>
extern "C"
{
void throw_and_catch_exception()
{
try
{
throw std::runtime_error("test throw error");
}
catch (...)
{
// ignore this exception
}
}
}
package testcgos
/*
void throw_and_catch_exception();
*/
import "C"
func Callthrow_and_catch_exception() {
C.throw_and_catch_exception()
}
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