Thread overview
Re: Shouldn't c_long and c_ulong be library typedefs?
Sep 06, 2012
Jonathan M Davis
Sep 06, 2012
Iain Buclaw
Sep 06, 2012
Andrej Mitrovic
September 06, 2012
On Thursday, September 06, 2012 01:52:01 Andrej Mitrovic wrote:
> Anyway I've two questions:
> 1) Has anyone come up with a library solution for a typedef because I
> need it for cases like these, and
> 2) Will c_long/c_ulong be converted to a library typedef or will they
> remain aliases?

Considering that the only reason to use c_long and its ilk is because you have an extern(C) function, I wouldn't expect Typedef to have anything to do with it, because that would be D struct. I'd always expect them to be aliases. If you really have two functions which conflict because the same size integer, then you really have two functions which conflict. I'm fairly sure that the C linker is going to see any difference between int and long either if long is the same size as int (though I could be wrong).

So, if you're trying to overload based on integral types which can change size depending on the architecture, I'd advise that you use static if so that only one of them is defined when they're the same. You shouldn't have both of them if the integral types are actually the same size, because then you have two functions with the exact same signature, regardless of what the actual names of the types are.

- Jonathan M Davis
September 06, 2012
On 6 September 2012 00:52, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> I'm interfacing with C++ and found a little overload problem:
>
> C++:
> void test(unsigned int x)  { }
> void test(unsigned long x) { }
>
> int main()
> {
>     unsigned int x;
>     unsigned long y;
>     test(x);
>     test(y);
>     return 0;
> }
>

Interfacing is the least of your problems. D is also unable to mangle 'unsigned long' in C++ correctly either. :^)


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
September 06, 2012
On 9/6/12, Iain Buclaw <ibuclaw@ubuntu.com> wrote:
> Interfacing is the least of your problems. D is also unable to mangle 'unsigned long' in C++ correctly either. :^)

Mangling isn't a problem for me though. :)