mercredi 11 mars 2015

Calling C++ Application Code from C library?

Folks, Assuming I have a c++ application / library running which implements say



/* Alloc API */
void* my_alloc(int size) {
return malloc(sizeof(size));
}


This is not under "extern c".


I have a C dynamic library from which I need to call my_alloc, can I directly call that API?



Like,

int test_my_alloc (int size) {
int *x;

x = (int*)my_alloc(size);
if (x == NULL) {
return 0;
} else {
return 1;
}
}

Aucun commentaire:

Enregistrer un commentaire