Permalink
Browse files

Added dead simple ctypes example

  • Loading branch information...
1 parent f067550 commit 57e6d6fa003e2878e633a98054aa69531ef44594 @hammer committed Jun 4, 2012
Showing with 17 additions and 0 deletions.
  1. +10 −0 ctypes/example1/README.md
  2. +7 −0 ctypes/example1/hello.c
View
@@ -0,0 +1,10 @@
+To build the shared library on Mac OS X:
+
+ $ gcc -shared -Wl,-install_name,hello.so -o hello.so -fPIC hello.c
+
+
+To use:
+
+ >>> import ctypes
+ >>> hello = ctypes.CDLL('hello.so')
+ >>> hello.myprint()
View
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void myprint(void);
+
+void myprint() {
+ printf("hello world\n");
+}

0 comments on commit 57e6d6f

Please sign in to comment.