D2.0 cpp interfacing: what is a C++ unsigned long counterpartinD?
BCS
none at anon.com
Sat Oct 3 17:48:03 PDT 2009
Hello Denis,
> On Sun, 04 Oct 2009 01:48:38 +0400, Michel Fortin
> <michel.fortin at michelf.com> wrote:
>
>>>
>> 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.
>
It's a low level workaround and anyone who write them by hand is being foolish.
The primary cases I see it being used in are be tool generated header files
build from c++ header files and or object files or with some kind of template+CTFE
support.
> 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...
>
Whatever the overall solution, I think something along the lines of Denis'
or my idea is the correct primitive to build it on.
More information about the Digitalmars-d
mailing list