chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Check for NULL struct


From: Kon Lovett
Subject: Re: [Chicken-users] Check for NULL struct
Date: Tue, 29 Mar 2011 09:53:58 -0700


On Mar 29, 2011, at 9:46 AM, Cosme Enmanuel Zamudio Salazar wrote:

Is there a way to check for a NULL structure returned from a C function?

this is the structure

(define-record sdl-surface pointer)

(define-record-printer (sdl-surface s out)
  (for-each (lambda (x) (display x out))
            (list "#<sdl-surface "(sdl-surface-pointer s)">")))

(define-foreign-type SDL_Surface (c-pointer "SDL_Surface")
  sdl-surface-pointer
  make-sdl-surface)


the NULL can be returned when i try to load an image that doesnt exists:

#;12> (img-load "test.png")
#<sdl-surface #f>

but how do i check if its NULL ?

The Chicken FFI maps a c-pointer NULL to #f as an argument & as a return value. The `pointer' field is #f above.

I must be missing something.


Thanks :)
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users




reply via email to

[Prev in Thread] Current Thread [Next in Thread]