www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6121] New: Can't link with DMC C++ generated functions with long arguments

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

           Summary: Can't link with DMC C++ generated functions with long
                    arguments
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



11:11:04 PDT ---
foo.d:
extern(C++) void test(int);
void main()
{
    test(1);
}

bar.cpp:
void test(long)
{
};

$ dmc -c -cpp bar.cpp
$ dmd foo.d bar.obj
http://www.digitalmars.com/ctg/optlink.html
foo.obj(foo)
 Error 42: Symbol Undefined ?test  YAXH Z (void cdecl test(int ))

Symbol reference in foo.obj (D):
?test  YAXH Z
Symbol in bar.obj (CPP):
?test  YAXJ Z

According to this page: http://www.digitalmars.com/ctg/ctgMemoryModel.html ,
long in DMC has the same size as int in D. I've tried various other types but
nothing works.

Only if I change bar.cpp's test to:
void test(int){}

then it will compile and link. So how am I supposed to link with C++ functions
that take a long if I can't change them?

Due to this bug I can't link DDMD with the backend of DMD 2.053.

Also, your DMC echoes 8.42n instead of 8.52c, fyi.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6121


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
I believe that that's why druntime uses the alias c_long.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6121




15:50:12 PDT ---
Right, c_long is an alias to int on Windows. It still won't link, but a comment
in another thread might lead me to believe that this is just a name-mangling
problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 11 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6121


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |INVALID



This _is_ a name mangling problem.  D's long is not the same as C's long (at
least not on x86) and should not be mangled the same.  There is currently no
way to have dmd mangle a C or C++ function with a C long argument.

As dmd is working as designed, I'm going to close this as invalid.  You should
reopen as an enhancement request if you think dmd should be changed to do
things differently. (There is also already an enhancement request issue 2698
which would solve your problem)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 12 2011