digitalmars.D.learn - Bindings to C library.
- nikita (9/9) Sep 21 2009 Hello.
- nikita (10/10) Sep 22 2009 A-argh! Sorry, it's my inattention :)
- Jeremie Pelletier (3/15) Sep 22 2009 If you are using D2, it should be:
- nikita (2/5) Sep 22 2009 I'm using D1, but anyway thanks for help.
- Trass3r (3/5) Sep 22 2009 size_t is defined in Object.d, so it's better to use it for 64Bit
- nikita (2/8) Sep 22 2009 Oh, big thanks! I didn't know that.
Hello. I've started to learn D and now I'm trying to create a binding for libenca, but how do i translate the statement below? | const char** enca_get_languages (size_t *n); Citation from Enca's library reference manual: | Returns list of known languages. | The returned strings are two-letter ISO-639 language codes, the same as enca_analyser_alloc() accepts. | The list of languages has to be freed by caller; the strings themselves must be considered constant and must NOT be freed. | n : The number of languages will be stored here. | Returns : The list of languages, storing their number into *n.
Sep 21 2009
A-argh! Sorry, it's my inattention :) All was very simple. Interface to c library: extern(C) char** enca_get_languages(uint*); and in main module (i'm using tango.stdc.stringz): uint nb_lang; char** row = enca_get_languages(&nb_lang); for (uint y = 0; y < nb_lang; y++) { Stdout(fromStringz(row[y])).newline(); }
Sep 22 2009
nikita wrote:A-argh! Sorry, it's my inattention :) All was very simple. Interface to c library: extern(C) char** enca_get_languages(uint*); and in main module (i'm using tango.stdc.stringz): uint nb_lang; char** row = enca_get_languages(&nb_lang); for (uint y = 0; y < nb_lang; y++) { Stdout(fromStringz(row[y])).newline(); }If you are using D2, it should be: extern(C) const(char**) enca_get_languages(size_t*);
Sep 22 2009
Jeremie Pelletier Wrote:If you are using D2, it should be: extern(C) const(char**) enca_get_languages(size_t*);I'm using D1, but anyway thanks for help.
Sep 22 2009
nikita schrieb:extern(C) char** enca_get_languages(uint*);size_t is defined in Object.d, so it's better to use it for 64Bit compatibility.
Sep 22 2009
Trass3r Wrote:nikita schrieb:Oh, big thanks! I didn't know that.extern(C) char** enca_get_languages(uint*);size_t is defined in Object.d, so it's better to use it for 64Bit compatibility.
Sep 22 2009