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

Luís Oliveira luismbo at gmail.com
Wed Mar 19 08:35:19 UTC 2014


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

How is the String type defined in C? Also, why are you wrapping the C++ API
rather than the C API?

-- 
Luís Oliveira
http://kerno.org/~luis

(sent from my phone)
On Mar 19, 2014 3:44 AM, "Joeish W" <joeish80829 at yahoo.com> wrote:
>
> 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++.
>

>
> 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/20140319/a9036da3/attachment.html>


More information about the cffi-devel mailing list