c-define-type & tag
Assuming the following C code: struct Point {int x; int y;}; struct PointEx {int x; int y; int z;}; PointEx* getPointEx(); int length(Point*); And its Scheme-interface: (c-define-type Point "Point") (c-define-type Point* (pointer Point)) (c-define-type PointEx "PointEx") (c-define-type PointEx* (pointer PointEx)) (define get-PointEx (c-lambda () PointEx* "getPointEx")) (define Point-length (c-lambda (Point*) int "length")) How do you use type tags properly? Doing (c-define-type PointEx* (pointer PointEx Point*)) still generates a warning in the case below. How do you write these so the C macro casts into Point* and not PointEx*? (Point-length (get-PointEx)) The workaround is to write: (define Point-length (c-lambda (Point*) int "___result = length((Point*)___arg1);")) but I still want to clarify my understanding of tags and release functions. BTW, I get many more warnings. I think it is because "int(x) = 3;" isn't a correct lvalue anymore. It does work because "int" is POD, but in fact this is a constructor call for any non-POD. -- Stephane! coleste@videotron.ca (Stephane Le Cornec) +------------------- Made with recycled electrons. --------------------+ | #include <disclaimer.h> Kebekkujin desu. | +---------<http://www.starfiredesign.com/starfire/index.html>----------+
Afficher les réponses par date
participants (1)
-
Stephane Le Cornec