Covert a complex C header to D
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 2 17:00:04 PDT 2017
On Sunday, 2 April 2017 at 21:43:52 UTC, biocyberman wrote:
> template __KHASH_TYPE(string name){
> "struct kh_" ~ name ~"_t { " ~
> "khint_t n_buckets, size, n_occupied,
> upper_bound; " ~
> "khint32_t *flags; " ~
> "khkey_t *keys; " ~
> "khval_t *vals; " ~
> "}"
>
> }
Not that you'll get bitten by it in this case but in D the
pointer declarator * is left associative.
i.e. in C
int *pInt, Int; // "Int" is int not an int*
int *pInt, Int[3]; // Int is a static array of 3 ints.
but in D
misleading:
int *pInt, Int; // Int is an int*!!
wrong:
int *pInt, three_Ints[3]; // Error cannot mix declared types
not misleading
int* pInt, pInt2; // BOTH int*
int*pInt; //pointer to int
int[3] three_Ints; // static array of 3 ints.
More information about the Digitalmars-d-learn
mailing list