<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span>Thanks alot Martin ...that worked like a charm! =)</span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Friday, October 25, 2013 4:20 AM, Martin Simmons <martin@lispworks.com> wrote:<br> </font> </div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div class="y_msg_container">>>>>> On Thu, 24 Oct 2013 17:30:49 -0700 (PDT), Joeish W said:<div class="yqt1298461767" id="yqtfd28433"><br
clear="none">> <br clear="none">> here is the defcfun and deffun combo<br clear="none">> <br clear="none">> ;; void cvSplit(const CvArr* src, CvArr* dst0, CvArr* dst1, CvArr* dst2, CvArr* dst3) <br clear="none">> ;; Note: I had to use "CV-MERGE" instead of "MERGE" for the Common Lisp name of CV-MERGE so I named this <br clear="none">> ;; function CV-SPLIT so they would match. <br clear="none">> (cffi:defcfun ("cvSplit" %split) :void <br clear="none">> (src cv-arr) <br clear="none">> (dest-0 cv-arr) <br clear="none">> (dest-1 cv-arr) <br clear="none">> (dest-2 cv-arr) <br clear="none">> (dest-3 cv-arr)) <br clear="none">> <br clear="none">> (defun cv-split (src dest-0 &optional (dest-1 (cffi:null-pointer)) (dest-2 (cffi:null-pointer)) (dest-3 (cffi:null-pointer))) <br clear="none">> "Divides a multi-channel array into several single-channel arrays." <br
clear="none">> (%split src dest-0 dest-1 dest-2 dest-3)) <br clear="none">> <br clear="none">> <br clear="none">> it works as expected ...no errors at all<br clear="none">> <br clear="none">> my attempt at a macro(new to macros) below works in one piece of code when the defun it is in is evaluated at the repl then ran at the repl<br clear="none">> <br clear="none">> <br clear="none">> ;; #define cvCvtPixToPlane cvSplit <br clear="none">> (defmacro cvt-pix-to-plane (src dest-0 &optional (dest-1 (cffi:null-pointer)) <br clear="none">> (dest-2 (cffi:null-pointer)) (dest-3 (cffi:null-pointer))) <br clear="none">> "Macro for CV-SPLIT" <br clear="none">> `(cv-split ,src ,dest-0 ,dest-1 ,dest-2 ,dest-3))<br clear="none">> <br clear="none">> but in the same code when
used the exact same way inside emacs (using slime/sbcl on ubuntu saucy) when it is placed inside a newly opened file (.lisp) or even my well used test.lisp file and ran with slime-compile-and-load-file i get<br clear="none">> <br clear="none">> <br clear="none">> <br clear="none">> error: <br clear="none">> Objects of type SB-SYS:SYSTEM-AREA-POINTER can't be dumped into fasl files.<br clear="none">> --> CL-OPENCV::CV-SPLIT <br clear="none">> ==><br clear="none">> #.(SB-SYS:INT-SAP #X00000000)<br clear="none">> <br clear="none">> can you help me figure out the issue and write macros with null-pointers correctly</div><br clear="none"><br clear="none">This is a common gotcha with &optional/&key in macros: the default value is<br clear="none">evaluated during macroexpansion, so in general it
should be a form.<br clear="none"><br clear="none">I.e. you need `(cffi:null-pointer) instead of (cffi:null-pointer).<br clear="none"><br clear="none">__Martin<div class="yqt1298461767" id="yqtfd12254"><br clear="none"><br clear="none"></div><br><br></div> </blockquote> </div> </div> </div> </div></body></html>