[Ecls-list] Problems with clines

Steve Smith tarka at internode.on.net
Sun Aug 19 04:14:55 UTC 2007


Hi,

Can someone tell me what is wrong with the following:

  (defpackage "select-test"
    (:use "CL" "FFI"))
    (in-package "select-test")
  
  (clines "#include <sys/select.h>")
  
  (defun test-fun ()
    (clines "fd_set read_fds, write_fds;"
            "FD_ZERO(&read_fds);"
            "FD_ZERO(&write_fds);")
    ;; ....
    ;; Some other code resulting in an fd, but we'll use stdin here
    ;; ....
    (c-inline (fd) (:int) :void 
              "FD_SET(#0, &read_fds);"
              :one-liner nil
              :side-effects t))

Compiling this fails with errors, as all the 'clines' code is placed
into the header rather than inline.  Is this deliberate?

Converting the clines to c-inline fixes this issue but raises another
one; the resulting C source ends up like:

    static cl_object L1test_fun()
    { VT2 VLEX2 CLSR2
       cl_object value0;
       {
    TTL:
          fd_set read_fds, write_fds;
          FD_ZERO(&read_fds);
          FD_ZERO(&write_fds);

          FD_SET(((int)0), &read_fds);
          value0=Cnil; NVALUES=1;
          return value0;
       }
    }

Placing the variable declaration after the 'TTL:' breaks.

Any suggestions on the right way to do this would be appreciated.

Thanks,
Steve




More information about the ecl-devel mailing list