D2.0 cpp interfacing: what is a C++ unsigned long counterpart inD?

Denis Koroskin 2korden at gmail.com
Sat Oct 3 15:24:35 PDT 2009


On Sun, 04 Oct 2009 01:48:38 +0400, Michel Fortin  
<michel.fortin at michelf.com> wrote:

> On 2009-10-03 17:13:45 -0400, BCS <none at anon.com> said:
>
>> Hello Denis,
>>
>>> That's not always possible. Imagine LGPL'd code, or code which is
>>> distributed in precompiled form only (header + library).
>>>
>>  would, explicitly stating the mangled name work?
>>  pragam(mangle, "mangled name") // proposed feature
>> extern(C++) uint SomeFunction();
>
> Why not just:
>
> 	extern(C++, "mangled name") uint SomeFunction();
>
> where "mangled name" could be any constant expression?
>
> Whatever the syntax, this is a great idea. With constant expressions for  
> mangled names someone could create a compile-time function or a template  
> creating mangled names for namespaced functions and member functions.  
> You could change that function/template to match any C++ compiler you  
> want.
>
>

I thought about that, too. This is a good idea, but it's also too  
compiler-specific and somewhat error-prone.

I also thought about some Mangler template, which is capable of generating  
a mangled name for a given function at compile time, and using it instead  
of some pre-generated string.
This is a more generic solution, one could substitute different manglers  
for different compiler vendors.

In this case, I could "typedef uint unsigned_long;" and my mangler would  
recognize unsigned_long and mangle it differently from uint.

Just an idea...



More information about the Digitalmars-d mailing list