Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFFI is warning of deprecated useage of bare references to struct types #6

Open
jkcunningham opened this issue Jan 28, 2014 · 5 comments

Comments

@jkcunningham
Copy link

This error message showing up in several projects I maintain which employ cl-gd:

;; STYLE-WARNING:
;; bare references to struct types are deprecated. Please use (:POINTER (:STRUCT CL-GD::GD-IMAGE))
;; or (:STRUCT CL-GD::GD-IMAGE) instead.

I've put together a simple case which exhibits the behavior. It seems to be the WITH-THICKNESS macro causing the warning in this case:

(ql:quickload "cl-gd")
(use-package :cl-gd)

(let* ((x1 -86)
(x2 529)
(y1 -0.13)
(y2 1.16)
(xv '(0.0 1.0 2.0 3.0 4.0))
(yv '(0.99 0.12 0.66 0.24 0.075)))
(with-image* (500 250)
(allocate-color 255 255 255)
(let ((c (allocate-color 0 0 255)))
(with-transformation (:x1 x1 :x2 x2 :y1 y1 :y2 y2)
(with-thickness (1)
(mapl #'(lambda (x y)
(when (and (cdr x) (cdr y))
(draw-line (car x) (car y) (cadr x) (cadr y) :color c))) xv yv))
(write-image-to-file "test.png" :if-exists :supersede)))))

If you take out the with-thickness macro call the message disappears.

I posted this to both the cl-gd-devel and cffi-devel lists. Liam Healy from the latter sent this response:

"It's harmless, it's just telling you that the syntax that cl-gd uses for structure arguments will eventually (in a future version of CFFI) not work. The messages describes the problem. The structure is specified as cl-gd::gd-image in a function argument or return value. In the old versions of CFFI, that was interpreted as a pointer to that structure, because there was no other possibility. Now structures can also be passed/returned by value using cffi-libffi, so you have to say explicitly as the error message indicates. They might also need to change the use of #'mem-aref (which before returned a pointer to the structure but now returns the structure itself) into a #'mem-aptr."

Much obliged.
--Jeff Cunningham

@hanshuebner
Copy link
Member

I analysed the problem and found it to be twofold: CFFI-UFFI-COMPAT does not provision for passing struct and struct pointer parameters correctly, and CL-GD does not try to either.

I attempted to fix the problem in CFFI (https://github.com/edicl/cffi) and also (https://github.com/edicl/cl-gd/tree/cffi-uffi-warning) but I was not able to completely get it right. I may get back to this at some point, but for now, I'm leaving it to be fixed when it really causes issues other than the warning.

@bobbysmith007
Copy link

Thanks for putting some work into this on CFFI-UFFI-COMPAT. I have been running clsql with this package and am suddenly getting tons of style-warnings (after a quicklisp upgrade).

This is how I resolved the issue: cffi/cffi#35

@jkcunningham
Copy link
Author

On 02/08/2014 11:34 PM, Hans Hübner wrote:

I analysed the problem and found it to be twofold: CFFI-UFFI-COMPAT
does not provision for passing struct and struct pointer parameters
correctly, and CL-GD does not try to either.

I attempted to fix the problem in CFFI (https://github.com/edicl/cffi)
and also (https://github.com/edicl/cl-gd/tree/cffi-uffi-warning) but I
was not able to completely get it right. I may get back to this at
some point, but for now, I'm leaving it to be fixed when it really
causes issues other than the warning.


Reply to this email directly or view it on GitHub
#6 (comment).

Is there any chance your changes have broken hunchentoot? I just did a
fresh install of quicklisp on a VPS and hunchentoot install died like this:

215,969 bytes in 0.17 seconds (1205.18KB/sec)
; Loading "hunchentoot"
[package bordeaux-threads]........................
[package usocket].................................
[package rfc2388].................................
[package md5].....................................
[package trivial-garbage].........................
[package impl-specific-gray]......................
[package trivial-gray-streams]....................
[package flexi-streams]...........................
..................................................
..................................................
[package cl+ssl]..........
; file:
/home/jcunningham/quicklisp/dists/quicklisp/software/cl+ssl-20140211-git/bio.lisp
; in: DEFUN MAKE-BIO-LISP-METHOD
; (SETF (CFFI:FOREIGN-SLOT-VALUE CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD) 'TYPE)
; CL+SSL::+BIO-TYPE-SOCKET+)
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE1 CL+SSL::M '(:STRUCT CL+SSL::BIO-METHOD)
; 'TYPE)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE1 M
...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::NAME) (CFFI:FOREIGN-STRING-ALLOC "lisp"))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE7 CL+SSL::M '(:STRUCT CL+SSL::BIO-METHOD)
; 'CL+SSL::NAME)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE7 M
...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::BWRITE) (CFFI:CALLBACK
CL+SSL::LISP-WRITE))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE9 CL+SSL::M '(:STRUCT CL+SSL::BIO-METHOD)
; 'CL+SSL::BWRITE)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE9 M
...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::BREAD) (CFFI:CALLBACK CL+SSL::LISP-READ))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE11 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::BREAD)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE11
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::BPUTS) (CFFI:CALLBACK CL+SSL::LISP-PUTS))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE13 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::BPUTS)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE13
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::BGETS) (CFFI-SYS:NULL-POINTER))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE15 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::BGETS)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE15
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::CTRL) (CFFI:CALLBACK CL+SSL::LISP-CTRL))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE17 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::CTRL)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE17
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::CREATE) (CFFI:CALLBACK
CL+SSL::LISP-CREATE))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE19 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::CREATE)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE19
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::DESTROY) (CFFI:CALLBACK
CL+SSL::LISP-DESTROY))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE21 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::DESTROY)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE21
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (SETF (CL+SSL::SLOT 'CL+SSL::CALLBACK-CTRL) (CFFI-SYS:NULL-POINTER))
; --> LET* MULTIPLE-VALUE-BIND LET PROGN
; ==>
; (CFFI::FOREIGN-SLOT-SET #:STORE23 CL+SSL::M '(:STRUCT
CL+SSL::BIO-METHOD)
; 'CL+SSL::CALLBACK-CTRL)
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI::FOREIGN-SLOT-SET #:STORE23
M ...). Use
; BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; (CFFI:FOREIGN-ALLOC '(:STRUCT CL+SSL::BIO-METHOD))
;
; caught ERROR:
; during compiler-macroexpansion of (CFFI:FOREIGN-ALLOC '(:STRUCT
BIO-METHOD)).
; Use BREAK-ON-SIGNALS to intercept:
;
; Unknown CFFI type: :STRUCT.

; in: DEFUN CLEAR-RETRY-FLAGS
; (SETF (CFFI:FOREIGN-SLOT-VALUE CL+SSL::BIO '(:STRUCT CL+SSL::BIO)
; 'CL+SSL::FLAGS)
; (LOGANDC2
; (CFFI:FOREIGN-SLOT-VALUE CL+SSL::BIO '(:STRUCT CL+SSL::BIO)
; 'CL+

Regards,
--Jeff

@jimka2001
Copy link

I'm getting 100s/1000s of these warnings as well using gtk. It would be nice if I could fix it, work around, or suppress the warnings as they potentially hide other important output.

STYLE-WARNING:
bare references to struct types are deprecated. Please use (:POINTER
(:STRUCT
GTK::TREE-ITER-CSTRUCT)) or (:STRUCT
GTK::TREE-ITER-CSTRUCT) instead.

STYLE-WARNING:
bare references to struct types are deprecated. Please use (:POINTER
(:STRUCT
GTK::TREE-ITER-CSTRUCT)) or (:STRUCT
GTK::TREE-ITER-CSTRUCT) instead.

@jimka2001
Copy link

I've created a pull-request for CFFI which simply suppresses the style warning.
cffi/cffi#61

tomscii added a commit to tomscii/cl-xcb-xlib that referenced this issue Jan 16, 2023
These warnings were produced at runtime in potentially very large
quantities.

An example warning:
WARNING:
   bare references to struct types are deprecated.
   Please use (:POINTER
               (:STRUCT
                XCB:XCB-CHARINFO-T))
           or (:STRUCT
               XCB:XCB-CHARINFO-T) instead.

Not all call sites of map-result-list were changed; for the ones left
intact, I believe the calls are made with a non-struct type.

Some references to the same issue elsewhere on GitHub:
- edicl/cl-gd#6
- cffi/cffi#61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants