diff --git a/examples/ch2-07/hello-so/Makefile b/examples/ch2-07/hello-so/Makefile index 68d7737..f76a8b0 100644 --- a/examples/ch2-07/hello-so/Makefile +++ b/examples/ch2-07/hello-so/Makefile @@ -3,6 +3,9 @@ default: gcc -Wall _test_so.c ./say-hello.so ./a.out +run-py3: + python3 hello.py + clean: -rm *.so -rm *.out diff --git a/examples/ch2-07/hello-so/hello.py b/examples/ch2-07/hello-so/hello.py new file mode 100644 index 0000000..a5b01ec --- /dev/null +++ b/examples/ch2-07/hello-so/hello.py @@ -0,0 +1,9 @@ +from ctypes import * + +libso = CDLL("./say-hello.so") + +SayHello = libso.SayHello +SayHello.argtypes = [c_char_p] +SayHello.restype = None + +SayHello(c_char_p(b"hello"))