www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15843] New: D-type mangling used for extern(C) (extern)


          Issue ID: 15843
           Summary: D-type mangling used for extern(C) (extern) function
                    declaration inside function body, on LDC, GDC, and
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lasssafin gmail.com

void main() {
        extern(C) extern int func(int);
        static assert(func.mangleof == "_D1x4mainFZ4funcUiZi");

It is mangled as such on all 3 major compilers.

Using "pragma(mangle, "func")" as an attribute for func gives:
x.d(4): Error: unrecognized pragma(mangle)
x.d(6): Error: undefined identifier 'func'
x.d(7): Error: undefined identifier 'func'

Seemingly, the only user-side fix is moving the declaration out of the function

Mar 28 2016