www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Binding to GSL library

reply Radek <radoslaw.w.zielinski gmail.com> writes:
Hi, I'm making a trying to bind a gsl library 
http://www.gnu.org/software/gsl/ so far it was working but when i 
started binding complex numbers some functions won't work, like 
trigonometric functions - called they return null.

in gsl code complex struct looks like:

typedef struct
   {
     double dat[2];
   }
gsl_complex;


my complex struct looks like that:

struct _gsl_complex {
   double dat[2];
}
alias gsl_complex = _gsl_complex*;

So, what im doing wrong?
Nov 25 2015
next sibling parent reply drug <drug2004 bk.ru> writes:
On 25.11.2015 19:11, Radek wrote:
 Hi, I'm making a trying to bind a gsl library
 http://www.gnu.org/software/gsl/ so far it was working but when i
 started binding complex numbers some functions won't work, like
 trigonometric functions - called they return null.

 in gsl code complex struct looks like:

 typedef struct
    {
      double dat[2];
    }
 gsl_complex;


 my complex struct looks like that:

 struct _gsl_complex {
    double dat[2];
 }
 alias gsl_complex = _gsl_complex*;

 So, what im doing wrong?
A little bit offtopic but do you know about https://github.com/abrown25/gsld? It would be nice to join efforts.
Nov 25 2015
parent reply Radek <radoslaw.w.zielinski gmail.com> writes:
i have found bug. It shoul be
alias gsl_complex = _gsl_complex;
not
alias gsl_complex = _gsl_complex*;

On Wednesday, 25 November 2015 at 16:35:06 UTC, drug wrote:
 A little bit offtopic but do you know about 
 https://github.com/abrown25/gsld? It would be nice to join 
 efforts.
Sure, I'll share my code :) Ask me next month. That what I'm doing is my student project and first i need to complete it :)
Nov 25 2015
parent Andrew <aabrown24 hotmail.com> writes:
On Wednesday, 25 November 2015 at 16:45:51 UTC, Radek wrote:
 i have found bug. It shoul be
 alias gsl_complex = _gsl_complex;
 not
 alias gsl_complex = _gsl_complex*;

 On Wednesday, 25 November 2015 at 16:35:06 UTC, drug wrote:
 A little bit offtopic but do you know about 
 https://github.com/abrown25/gsld? It would be nice to join 
 efforts.
Sure, I'll share my code :) Ask me next month. That what I'm doing is my student project and first i need to complete it :)
Hi, I've been a little slow updating that repository because of work, and I got a little stuck with function pointers, I hope to get back to it soon. It would be lovely if it's all finished by that time :)
Nov 26 2015
prev sibling next sibling parent lobo <swamplobo gmail.com> writes:
On Wednesday, 25 November 2015 at 16:11:56 UTC, Radek wrote:
 Hi, I'm making a trying to bind a gsl library 
 http://www.gnu.org/software/gsl/ so far it was working but when 
 i started binding complex numbers some functions won't work, 
 like trigonometric functions - called they return null.

 in gsl code complex struct looks like:

 typedef struct
   {
     double dat[2];
   }
 gsl_complex;


 my complex struct looks like that:

 struct _gsl_complex {
   double dat[2];
 }
 alias gsl_complex = _gsl_complex*;

 So, what im doing wrong?
I believe if you're interfacing with C you should use __gshared: alias gsl_complex = __gshared _gsl_complex*; bye, lobo
Nov 25 2015
prev sibling parent Artur Skawina via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On 11/25/15 17:11, Radek via Digitalmars-d-learn wrote:
 Hi, I'm making a trying to bind a gsl library http://www.gnu.org/software/gsl/
so far it was working but when i started binding complex numbers some functions
won't work, like trigonometric functions - called they return null.
 
 in gsl code complex struct looks like:
 
 typedef struct
   {
     double dat[2];
   }
 gsl_complex;
 
 
 my complex struct looks like that:
 
 struct _gsl_complex {
   double dat[2];
 }
 alias gsl_complex = _gsl_complex*;
 
 So, what im doing wrong?
That's not a struct but a pointer to a struct. Also, you can just drop the `typedef` hack (which is used in C to avoid having to type the 'struct' keyword), so: struct gsl_complex { double[2] dat; } artur
Nov 26 2015