www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23415] New: ImportC: typedef'd struct as const parameter "is

https://issues.dlang.org/show_bug.cgi?id=23415

          Issue ID: 23415
           Summary: ImportC: typedef'd struct as const parameter "is not
                    callable"
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: acehreli yahoo.com

// c.c
typedef struct /* S_ */ {
  int i;
} S;

void foo(const S s) {}


// d.d
import c;

void main() {
    S s;
    foo(s);
}


Error: function `c.foo(__tag46 s)` is not callable using argument types
`(__tag45)`
       cannot pass argument `s` of type `__tag45` to parameter `__tag46 s`


Same issue if the parameter is 'const S *'.


The following are workarounds:

a) Uncomment S_ in c.c

b) Remove 'const' from the parameter

--
Oct 14 2022