www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4581] New: extern function pointers inside functions

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581

           Summary: extern function pointers inside functions
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: link-failure, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-08-04 01:47:41
PDT ---
import std.c.windows.windows;

The following code compiles, but does not link:

void main(string[] args) {
    extern (Windows) HINSTANCE ShellExecuteW(HWND, LPCWSTR, LPCWSTR,
        LPCWSTR, LPCWSTR, INT);

    HINSTANCE i = ShellExecuteW(null, "open",
"http://www.example.com", null, null, SW_SHOW);
}

Error 42: Symbol Undefined
__D4test4mainFAAyaZi13ShellExecuteWMWT4core3sys7windows7windows6HANDLEPxuPxuPxuPxuiZT4core3sys7windows7windows6HANDLE 24

As we can see, the symbol is D mangled, which it should not be.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com


--- Comment #1 from nfxjfg gmail.com 2010-08-04 09:05:38 PDT ---
It's a feature, not a bug. If the declaration is contained in something nested
(like a struct, I guess it also applies to functions), name extern doesn't
disable mangling.

You can ask Walter for the why.

However I didn't find this in the spec and I could be wrong, so I'll leave it
to others to find this and mark the bug as invalid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581



--- Comment #2 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-08-04 09:20:14
PDT ---
I cannot foresee any instance in which it is wanted that the compiler disregard
the extern declaration, and even if this is the case, there should at least be
a warning as it blithely ignores the programmer's intention.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581



--- Comment #3 from Sobirari Muhomori <dfj1esp02 sneakemail.com> 2010-08-04
10:07:30 PDT ---
You can't express intention with extern attribute, because it's ambiguous:
whether it specifies an external function or internal function with specific
calling convention. Currently there's no way to differentiate between these two
cases.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581



--- Comment #4 from Simen Kjaeraas <simen.kjaras gmail.com> 2010-10-26 15:22:51
PDT ---
(In reply to comment #3)
 You can't express intention with extern attribute, because it's ambiguous:
 whether it specifies an external function or internal function with specific
 calling convention. Currently there's no way to differentiate between these two
 cases.
But is there really a difference? Currently, extern( foo ) means 'use foo's calling conventions and name mangling'. As long as the latter is also part of the definition, I do not see such a difference. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 26 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4581


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-22
10:36:04 PST ---
Walter can we get your opinion on this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 22 2013