[Issue 7024] inconsistent mangling of shared in extern(C++)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 2 11:00:38 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=7024



--- Comment #6 from deadalnix <deadalnix at gmail.com> 2011-12-02 10:59:31 PST ---
(In reply to comment #4)
> Rather than trying to fix the C++ mangling, wouldn't it make more sense to
> disallow 'shared' in extern(C++) declarations?

As thoses concept doesn't exists in C++, this is up to the C++ programmer to
ensure that something is shared or not. Sometime, C++ code is just made to
handle shared data, it is just not explicit.

In this case, you ends up using convoluted casts to handle everything.

I have a practical case : start a thread from C++, but that could interract
with D (so you must go throw D's way of starting thread). You end up writing
something like this :
alias extern(C++) void* function(void*) EntryPoint;
extern(C++) void* D_start_thread(EntryPoint entryPoint, void* userData) {
    Tid tid = spawn(function void(EntryPoint entryPoint, shared void* userData)
{
        entryPoint(cast(void*) userData);
    }, entryPoint, cast(shared void*) userData);

    return cast(void*) [tid].ptr;
}

So I would recommand to ignore shared in mangling of C++ function and mangle
immutable as const. It is up to the programmer to ensure that thoses are right
qualifiers.

inout can't be handled nicely so it should generate a compile time error.

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


More information about the Digitalmars-d-bugs mailing list