Issue 23415 - ImportC: typedef'd struct as const parameter "is not callable"
Summary: ImportC: typedef'd struct as const parameter "is not callable"
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 major
Assignee: No Owner
URL:
Keywords: ImportC
Depends on:
Blocks:
 
Reported: 2022-10-14 22:33 UTC by Ali Cehreli
Modified: 2023-02-03 15:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ali Cehreli 2022-10-14 22:33:51 UTC
// 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
Comment 1 RazvanN 2023-02-03 09:30:25 UTC
I cannot reproduce this.
Comment 2 Ali Cehreli 2023-02-03 15:45:06 UTC
Yes, works with 2.101.2.