From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Jan Synacek Newsgroups: gmane.lisp.guile.user Subject: FFI questions Date: Fri, 15 May 2020 15:47:34 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="23096"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri May 15 15:48:05 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZah2-0005qL-ON for guile-user@m.gmane-mx.org; Fri, 15 May 2020 15:48:04 +0200 Original-Received: from localhost ([::1]:39278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZah1-0001CI-PJ for guile-user@m.gmane-mx.org; Fri, 15 May 2020 09:48:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZagq-0001Am-RF for guile-user@gnu.org; Fri, 15 May 2020 09:47:52 -0400 Original-Received: from us-smtp-2.mimecast.com ([205.139.110.61]:26736 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZagp-0000bh-Ug for guile-user@gnu.org; Fri, 15 May 2020 09:47:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589550470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=s3k2en2vd2skrauB1bStZ6o7ssAY4lxUqislGpf7bUA=; b=Z3ZU7o7oOnJYVI+DjvAMLDNaMS/nJvi4ySxQRvWDp1e6djULeRz6tmMhlK1i8pqLUumTec 62tmNdKI35mwwkGDISj1TkKaPZfcJF+EOru11H9cQzvW4+BrAiqV4JWRCaZmEtRx78p+fd 8lQqKoiDtLgWacR5KL3SyLvJT1vNKCk= Original-Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-nypDUKJCNwaE1niVWWO74g-1; Fri, 15 May 2020 09:47:48 -0400 X-MC-Unique: nypDUKJCNwaE1niVWWO74g-1 Original-Received: by mail-lj1-f199.google.com with SMTP id 21so268349ljr.18 for ; Fri, 15 May 2020 06:47:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Jv788f6xX3jtObrSEanr7C3xBwM92nqVl8sEpSIQQyA=; b=CevHONKk6go9Yveq1Xivswb67IhiXcAU5dBJgJXkkOsUxc84+pKhkWhypTgBl4woJv hbChIpWK3hGxct5ffPbadwlBAtBXxq8phO7za1VOf9OBVoIjOXb1PggV8JAzh3kbUTMf z+efIoQ9/+Ci5i67RI5PW/bMiW1qgUCeqxyGrHcsAYaKVK2vWpa2YIY+g+3Wv4JjJqQf yWiN+s9SnZunoN0a4czSj7tFzJqWMgi0oid2StT5vHqTVe3rAeUmANg1dmGzZ43HZAOE wr/D+PBJZHtrTIKnmtzYZWIwFRMkEbRT6ibAaeYPe2psKFzHMi7UwTBdwmuDTlQtn3S4 BbTQ== X-Gm-Message-State: AOAM533VAw/KaoqKp3x7eAE2GXOzleaWQofkSKOACmSrqTmtFJMj/7/K C9DtNEAKWBO6xPki9a7OTmkM1z9k79dIEoreM5jqaY7V9hyUsuX6cRX9xc0SD7TC+gxN3YrmvP3 /dqAyAcaehvX+lg9kzZSlHzCiU6E= X-Received: by 2002:ac2:4436:: with SMTP id w22mr2497712lfl.55.1589550466277; Fri, 15 May 2020 06:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP6VhNgMkaRelamHYwbdJfgA10G1NURsKy8Nx/at89jus6d3U7XcRyXLvMGxRyVQZTENm2O4Jnu89cafOz6Ak= X-Received: by 2002:ac2:4436:: with SMTP id w22mr2497700lfl.55.1589550465931; Fri, 15 May 2020 06:47:45 -0700 (PDT) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=jsynacek@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16449 Archived-At: Hello, Currently I have something like this: (define libxcb (dynamic-link "libxcb")) ... (define c-change-window-attributes (pointer->procedure void (dynamic-func "xcb_change_window_attributes" libxcb) (list '* uint32 uint32 '*))) (define (change-window-attributes conn win mask vals) (c-change-window-attributes conn win mask (bytevector->pointer vals))) The last argument to xcb_change_window_attributes is 'const void *' and I need to pass a u32 vector to it. As it is right now, it segfaults when I try passing #u32(something) to 'change-window-attributes'. Is it possible to make it accept a u32 vector using just Scheme or do I have to work around it on the C level? My second question is about FFI and structs. Is it possible to access C struct members from Scheme by name? If not, how do I generally approach the problem? I've checked how guile-xcb does it and it seems to be building hash tables with field names as keys. But that basically requires me to "redefine" all the C structs that I would be interested in at the Scheme level. Regards, -- Jan Synacek Software Engineer, Red Hat