extern "C" for C++
Vanroose
vanroose@ruca.ua.ac.be
Thu May 4 01:09:00 GMT 2000
DearÃÂ GSL-users,
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ As discussedÃÂ inÃÂ
the november archives of this mailing listÃÂ I have to includeÃÂ
aÃÂ 'extern "C" ' before I include the GSLÃÂ headerfile when I want
to use a gsl-function in C++.
ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ So I added toÃÂ my code
#ifdef __cplusplus
extern "C" {
#endif
#include <gsl_sf_result.h>
#include <gsl_sf_coulomb.h>
#include <gsl_sf_laguerre.h>
#include <gsl_sf_gamma.h>
#include <gsl_sf_erf.h>
#include <gsl_integration.h>
#ifdefÃÂ __cplusplus
}
#endif
ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ This results into problemsÃÂ
inÃÂ ÃÂ math.hÃÂ ÃÂ with function overloading
gcc -c -fpicÃÂ potential.cc -I/xopt/python1.5/include/python1.5
-I/home/edp/vanroose/archief/vanroose/Python-1.5.2/Numerical-14/Include/
-I/home/edp/vanroose/include/gsl/
In file included from /home/edp/vanroose/include/gsl/gsl_math.h:3,
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
from /home/edp/vanroose/include/gsl/gsl_integration.h:4,
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
from potential.cc:9:
/xopt/gnu/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/include/math.h:
In function `double pow(double, int)':
/xopt/gnu/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/include/math.h:74:
declaration of C function `double pow(double, int)' conflicts with
/xopt/gnu/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/include/math.h:71:
previous declaration `double pow(double, double)' here
/xopt/gnu/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/include/math.h:
In function `double pow(double, int)':
/xopt/gnu/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/include/math.h:75:
warning: `double' used for argument 2 of `pow(double, int)'
make: *** [potentialC] Error 1
ÃÂ
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WhenÃÂ
I look toÃÂ the math.h code that the compiler refers to
#ifdef _INCLUDE_HPUX_SOURCE
ÃÂ ÃÂ ÃÂ ÃÂ extern double log2(double);
#endif
ÃÂ ÃÂ ÃÂ ÃÂ extern double modf(double,
double *);
ÃÂ ÃÂ ÃÂ ÃÂ extern double pow(double,
double);
#ÃÂ ÃÂ ÃÂ ifdef __cplusplus
ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ ÃÂ inline double pow(double
__d,int __expon) {
ÃÂ return pow(__d,(double)__expon);
ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ ÃÂ extern "C" {
#else
#ÃÂ ÃÂ ÃÂ endif
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
It seemsÃÂ that when math.h is includedÃÂ the __cplusplus variable
is still set but due to the extern "C" derictive the code is compiled as
C. Or am I wrong??
ÃÂ
ÃÂ
More information about the Gsl-discuss
mailing list