@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c/setjmp"
|
||||
"github.com/goplus/llgo/c/setjmp/demo"
|
||||
"github.com/goplus/llgo/c/setjmp/trycatch"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -10,7 +10,7 @@ func main() {
|
||||
switch ret := setjmp.Sigsetjmp(&jb, 0); ret {
|
||||
case 0:
|
||||
println("Hello, setjmp!")
|
||||
demo.ThrowCppException()
|
||||
trycatch.ThrowCppException()
|
||||
setjmp.Siglongjmp(&jb, 1)
|
||||
default:
|
||||
println("exception:", ret)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
extern "C" void throwCppException();
|
||||
|
||||
int main() {
|
||||
try {
|
||||
throwCppException();
|
||||
} catch (...) {
|
||||
throw;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
13
c/setjmp/trycatch/_code/try_catch.cpp
Normal file
13
c/setjmp/trycatch/_code/try_catch.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <exception>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void throwCppException();
|
||||
|
||||
int main() {
|
||||
try {
|
||||
throwCppException();
|
||||
} catch (std::exception& e) {
|
||||
printf("Hi, %s\n", e.what());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package demo
|
||||
package trycatch
|
||||
|
||||
import (
|
||||
_ "unsafe"
|
||||
Reference in New Issue
Block a user