D interface for C library problems
Jacob Carlborg
doob at me.com
Mon Oct 15 04:42:40 PDT 2012
On 2012-10-15 13:37, Oleg wrote:
> 2. Have an error in static function:
> gpgme_err_code_t gpgme_err_code_from_syserror (void);
>
> static inline gpgme_error_t
> gpgme_error_from_syserror (void)
> {
> return gpgme_error (gpgme_err_code_from_syserror ());
> }
>
> When I write D code like this:
>
> gpgme_err_code_t gpgme_err_code_from_syserror();
>
> gpgme_error_t gpgme_error_from_syserror() {
> return gpgme_error(gpgme_err_code_from_syserror());
> }
>
> I got error:
>
> In function `gpgme_error_from_syserror':
> src/main.d:(.text.gpgme_error_from_syserror+0x5): undefined reference to
> `gpgme_err_code_from_syserror'
> --- errorlevel 1
> collect2: ld returned 1 exit status
>
> Anyone knows how to fix this?
>
> Thanks and sorry for my English.
You need to declare all functions you want to use from C as:
extern (C) gpgme_err_code_t gpgme_err_code_from_syserror();
Then you also need to link with the C library.
http://dlang.org/interfaceToC.html
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list