2
我需要在運行時打開多個共享庫。我不知道它們的數量(計數),所以我使用的動態內存分配:錯誤:'void *'在動態打開多個共享庫時不是指向對象類型的錯誤
void* handle= new void* [n]; // n refers to number of handles
handle[0] = dlopen("./fileN.so", RTLD_LAZY); // doesn't work : Error: ‘void*’ is not a pointer-to-object type
但是如果我做靜態分配,其工程─
void* handle[10];
handle[0] = dlopen("./file0.so", RTLD_LAZY); // works
這是爲什麼,當我動態訪問句柄,我收到錯誤?我該如何解決它?