noob in c macro preprocessor hell converting gsl library header files

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 6 05:36:03 PST 2016


I have been converting C numeric libraries and depositing them 
here: https://github.com/dataPulverizer. So far I have glpk and 
nlopt converted on a like for like c function basics. I am now 
stuck on the gsl library, primarily because of the preprocessor c 
code which I am very new to. The following few are particularly 
baffling to me:

#define INLINE_FUN extern inline // used in gsl_pow_int.h: 
INLINE_FUN double gsl_pow_2(const double x) { return x*x;   }

Could I just ignore the INLINE_FUN and use alias for function 
pointer declaration? For example ...

alias gsl_pow_2 = double gsl_pow_2(const(double) x);

#define INLINE_DECL // used in interpolation/gsl_interp.h: 
INLINE_DECL size_t gsl_interp_bsearch(const double x_array[], 
double x, size_t index_lo, size_t index_hi);

I would guess the same as for INLINE_FUN?

#define GSL_VAR extern // used in rng/gsl_rng.h:GSL_VAR const 
gsl_rng_type *gsl_rng_borosh13;

perhaps GSL_VAR can be ignored and I could use:

gsl_rng_borosh13 const(gsl_rng_type)*;

I have been using these kind of fixes and have not been able to 
get the rng module to recognise the ported functions, meaning 
that something has been lost in translation.

I am currently getting the following error:

$ gsl_rng_print_state

rng_example.o: In function `_Dmain':
rng_example.d:(.text._Dmain+0x13): undefined reference to 
`gsl_rng_print_state'
collect2: error: ld returned 1 exit status

I can't seem to call any of the functions but the types are 
recognized.

Thanks in advance



More information about the Digitalmars-d-learn mailing list