[cffi-devel] Creating a pointer to a C string

Joeish W joeish80829 at yahoo.com
Wed Mar 19 03:43:10 UTC 2014


I'm trying to recreate a const char* filename parameter for code I have that needs it...The function I'm wrapping is the OpenCV C++ function "imread" it is below in the documentation.  It is used to read an image(jpg etc) from a file and return a pointer to it


http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread

first I need to wrap in C as below calling  the const char* filename parameter as a String*
the below cv_imread does compile on ubuntu trusty using g++. And the function works as intended using g++.


Mat* cv_imread(String* filename, int flags) {
    return new Mat(cv::imread(*filename, flags));
}

I wrap in Lisp like this:

(defcfun ("cv_imread" %imread) (:pointer mat) 
  (filename (:pointer string*)) 
  (flags :int))


When I usually create a (:pointer string*) parameter I do it like this 


(window-name (foreign-alloc :string :initial-element "IMREAD Example"))
               

 and it works to supply strings that aren't filenames but when I try to use a filename both absolute and relative paths it fails...it also fails using double forward slashes in the pathname.


Any advice is appreciated and btw Emacs /SBCL is my Lisp IDE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20140318/fd72e676/attachment.html>


More information about the cffi-devel mailing list