manpagez: man pages & more
info bigloo
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

25.1.6.8 C opaques

This form defines opaque types.

 
<opaque-type> → (opaque)

Let us suppose the type:

 
(type opa (opaque) ...)

Bigloo creates the following functions:

Opaque types are relevant when a C value must transit via a Scheme function from a C function to another C function. The value can't be used in Scheme because no accessors are defined over that type it can only be send back to a C function.

Here is an example of Scheme code using opaque type.

 
(module foo
   (extern (type filedes (opaque) "FILE *")
           (macro _fopen::filedes (::string ::string) "fopen")
           (_fgetc::int (::filedes) "fgetc")
           (_fclose (::filedes) "fclose"))
   (export (fopen::filedes ::bstring ::bstring)
           (fclose ::filedes)
           (fgetc::char ::filedes)))

(define (fopen fname mode)
   (_fopen fname mode))

(define (fclose filedes)
   (_fclose filedes))

(define (fgetc filedes)
   (integer->char (_fgetc filedes)))

Note: To illustrate the default type compilation of extern function, we have voluntary introduced an incomplete declaration for the fclose function. This will make Bigloo to produce a warning when compiling that module.


© manpagez.com 2000-2026
Individual documents may contain additional copyright information.