Così ho questo codice:Come fanno dichiarare un puntatore a funzione extern "C"
#include "boost_bind.h"
#include <math.h>
#include <vector>
#include <algorithm>
double foo(double num, double (*func)(double)) {
return 65.4;
}
int main(int argc, char** argv) {
std::vector<double> vec;
vec.push_back(5.0);
vec.push_back(6.0);
std::transform(vec.begin(), vec.end(), vec.begin(), boost::bind(foo, _1, log));
}
E ricevere questo errore:
return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
.............................................................^
%CXX-E-INCOMPATIBLEPRM, argument of type "double (* __ptr64)(double) C" is
incompatible with parameter of type "double (* __ptr64)(double)"
detected during:
instantiation of ...5 pages of boost
Quindi questo errore è perché 'log' è extern "C " 'd in math.h
mi chiedevo come dichiarare la mia funzione argomento puntatore nella foo() in modo che gestisce extern "C"' d funzioni.
non che risponda alla tua domanda, ma questa particolare situazione non richiede 'boost :: bind',' std :: bind2nd' farebbe bene il lavoro. –