Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat foo.h foo.c make-shared-lib.sh foo.l example-foo.l
- #ifndef foo_h__
- #define foo_h__
- struct Rect
- {
- int x,y;
- int w,h;
- };
- void foo(struct Rect *r);
- #endif // foo_h__
- /* module foo.c */
- #include <stdio.h>
- #include "foo.h"
- void foo(struct Rect *r)
- {
- printf("Hello from foo!\n");
- printf("rect.x=%d\n", r->x);
- printf("rect.y=%d\n", r->y);
- printf("rect.w=%d\n", r->w);
- printf("rect.h=%d\n", r->h);
- }
- /* module foo.c */
- #!/bin/sh
- rm -f libfoo.so foo.o
- gcc -c -Wall -Werror -fpic foo.c && gcc -shared -o libfoo.so foo.o
- #end of script make-share-foolib.sh
- ######### foo.l ########################
- (default
- *foolib "./libfoo.so")
- (de foo (x y w h)
- #segfaults on calling of foo with params
- #(native `*foolib "foo" 'N (list NIL (16) (list (x . 4) (y . 4) (cons w 4) (cons h 4)))))
- #calls foo, but values are incorrect
- (native `*foolib "foo" 'N (list NIL (16) (list (4 . x) (4 . y) (cons 4 w) (cons 4 h)))))
- ######### foo.l ########################
- ####### example-foo.l ##################
- (load "foo.l")
- (foo 2132 32321 43432 43433)
- ########################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement