C to D bindings: how much do you D-ify the code?
Michel Fortin
michel.fortin at michelf.ca
Sat Oct 26 08:11:05 PDT 2013
On 2013-10-26 14:52:42 +0000, Mike Parker <aldacron at gmail.com> said:
> On 10/26/2013 9:09 PM, Benjamin Thaut wrote:
>> Am 25.10.2013 15:10, schrieb Lionello Lunesu:
>>>
>>> 1. enum names vs prefixes
>>> enum FOO { FOO_A, FOO_B }; -> enum FOO {A,B}
>>
>> I actually do number 1 whenever creating C bindings. Because its not
>> really DRY to write: FOO.FOO_A
>
> alias FOO = int;
> enum { FOO_A, FOO_B };
>
> Otherwise, it doesn't match the C API.
But then you lose the type-safety of an enum. Why not this:
enum FOO { FOO_A, FOO_B };
alias FOO.FOO_A FOO_A;
alias FOO.FOO_B FOO_B;
?
Overly verbose perhaps.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca
More information about the Digitalmars-d
mailing list