bugnyacc parser generator - Bugs: bug #59350, functions accepting structs...


bug #59350: functions accepting structs defined in a separate file

Submitter:  None
Submitted:  Mon 26 Oct 2020 12:08:38 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Postponed
Privacy:  Public Assigned to:  mwette
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:
       No canned response available


Fri 21 May 2021 07:34:11 PM UTC, comment #1: 

So I'm not sure how to handle this.  There are two options.
1) report an error that "struct bar is not in scope of ffi module"
2) make an anonymous struct.
I'm tempted to go with #1. 

Another option is to add an ffi-module option to add defs, like with a #:inc-defs '("struct bar")

What are you intending to pass to this if you don't include "struct bar" in the scope of your ffi-module.

Another option is to use the #:inc-filter to include bar.h.

(Note that the ffi-helper intentionally only includes converted type declarations from the list of includes and those you handle in the #:inc-filter predicate.)

Matt Wette <mwette>
Project Administrator
Mon 26 Oct 2020 12:08:38 PM UTC, original submission:  

If a function accepts a struct as a parameter and the struct is defined in an included file, compile-ffi will fail to process the file. Unlike bug #59307, this only affect cases where the struct defined in a separate file.

For example, suppose there are two files test.h and bar.h with the following contents.


#include "bar.h"

void foo(struct bar baz);


struct bar
        int x;
        int y;

Processing test.h with compile-ffi results in the following error:

mdecl->fh-unwrapper missed:
         (decl-spec-list (type-spec (fixed-type "int")))
         (comp-declr-list (comp-declr (ident "x"))))
         (decl-spec-list (type-spec (fixed-type "int")))
         (comp-declr-list (comp-declr (ident "y")))))))
In ice-9/boot-9.scm:
    829:9 19 (catch _ _ #<procedure 7f35ffb251e0 at scripts/compile…> …)
In scripts/compile-ffi.scm:
    233:8 18 (_)
In nyacc/lang/c99/ffi-help.scm:
   2199:4 17 (compile-ffi-file _ _)
In ice-9/ports.scm:
   445:17 16 (call-with-input-file _ _ #:binary _ #:encoding _ # _)
In system/base/compile.scm:
     43:4 15 (call-once _)
In ice-9/boot-9.scm:
    841:4 14 (with-throw-handler _ _ _)
In system/base/compile.scm:
    59:11 13 (_)
In nyacc/lang/c99/ffi-help.scm:
  2215:20 12 (_ #<closed: file 7f35ffb29d90>)
In unknown file:
          11 (eval (define-ffi-module (test) #:include (quote (#))) #)
In nyacc/lang/c99/ffi-help.scm:
  1966:10 10 (expand-ffi-module-spec (test) ((include "test.h")))
In sxml/fold.scm:
    89:21  9 (fold-values #<procedure 7f35ffb498e0 at nyacc/lang/…> . #)
In ice-9/boot-9.scm:
    829:9  8 (catch ffi-help-error #<procedure 7f35ffb3c540 at nyac…> …)
In nyacc/lang/c99/ffi-help.scm:
   1181:4  7 (cnvt-udecl _ _ () ("void" "float" "double" "short" # …))
  1068:22  6 (cnvt-fctn "foo" _ ((param-decl (decl-spec-list (…)) #)))
    864:5  5 (gen-exec-params ((param-decl (decl-spec-list (# …)) #)))
In srfi/srfi-1.scm:
   466:18  4 (fold #<procedure 7f3601286ec0 at nyacc/lang/c99/ffi-h…> …)
In nyacc/lang/c99/ffi-help.scm:
   875:31  3 (_ _ ())
    970:7  2 (mdecl->fh-unwrapper _)
In unknown file:
           1 (scm-error misc-error #f "~A" ("MDECL-FH-UNWRAPPER") #f)
In ice-9/boot-9.scm:
   752:25  0 (dispatch-exception _ _ _)

ice-9/boot-9.scm:752:25: In procedure dispatch-exception:

If the struct definition is moved into test.h, then compile-ffi processes the file successfully.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mwette (Posted a comment)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-21 mwette StatusNone Postponed
        Assigned toNone mwette

    Back to the top

    Powered by Savane 3.9