maybe its simple question but i really hope some one can give a hint.
It seems no problem to use extern “C” exporting functions from cpp, but now i mean to export function from .cu to ".cpp, and there’s comes problems. the function in .cu cannot reference the pointer in .cpp
/******* test.cpp *********/
…
extern “C”
void arrayMan( float, float );
int main () {
float x = new float[20];
float d = new float[20];
memset( x, 1, sizeof(float) * 20 );
memset( d, 2, sizeof(float) * 20 );
arrayMan( x, d );
cout<<“after d[3]=”<<d[3]<<endl;
return 0;
}
/******** arrayMan.cu *********/
extern “C”
void arrayMan( float, float );
void arrayMan( float* x, float* d ){
printf(“cu x[3]=%f\n”,x[3]);//should be 1
printf(“cu d[3]=%f\n”,d[3]);//should be 2
for( int i = 0; i<20; i++ ){
d[i] = x[i];
}
}
/********* output***************/
cu x[3] = 0.0000
cu d[3] = 0.0000
after d[3] = 2.36943e-38
so how can i reference the pointer array?