C++ interop - what to do about long and unsigned long?

Gary Willoughby via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 11 05:44:55 PDT 2014


On Wednesday, 10 September 2014 at 20:41:45 UTC, Walter Bright 
wrote:
> C++'s long and unsigned long can be accessed with c_long and 
> c_ulong. Unfortunately, these are aliases and mangle to their 
> underlying types.
>
> Meaning that there is no way to interface to a C++ function 
> declared as:
>
>     void foo(unsigned long);
>
> So, what to do about this?
>
> 1. elevate c_long and c_ulong into full fledged types.
>
> 2. create full fledged types __c_long and __c_ulong, and alias 
> c_long and c_ulong to them.
>
> 3. some sort of attribute?
>
> The same issue exists for C++'s 'long double'.

How would these choices affect/handle the dynamic nature of the 
current aliases? e.g. c_long on Windows is an int bu on Posix 
systems it can be int or long depending on the CPU architecture.


More information about the Digitalmars-d mailing list