www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22342] New: importC: Error: function 'func()' is not callable

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

          Issue ID: 22342
           Summary: importC: Error: function 'func()' is not callable
                    using argument types '(int)'
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

In C11, having an empty parentheses `()` is equivalent to D `(...)`, and so the
following should not error.
---
void func() { }
int main()
{
    func(12);
    func("12");
    func(1.2);
    return 0;
}
---

The correct code in order to induce the error we want is to use `(void)`
---
void func(void) { }
int main()
{
    func(12);    // error: too many arguments
    func("12");  // error: too many arguments
    func(1.2);   // error: too many arguments
    return 0;
}
---

--
Sep 28 2021