[Issue 22842] New: importC: Error: variable 'fun' cannot be declared to be a function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 18:01:05 UTC 2022


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

          Issue ID: 22842
           Summary: importC: Error: variable 'fun' cannot be declared to
                    be a function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

Declaring functions has two equivalent syntaxes.
---
int fun();
---
typedef int (tfunc)();
tfunc fun;
---

The latter is however rejected by the compiler.

Related code results in "Error: function 'fun' conflicts with variable 'fun'"
---
typedef int (myfunc)();
static myfunc fun;

int main()
{
    return fun();
}

int fun() // inherits "static" from declaration.
{
    return 0;
}

--


More information about the Digitalmars-d-bugs mailing list