2015-07-20 2 views
-4

Получение ошибки как void * не может быть назначено сущности типа char * 16 , что должно быть сделано для того, чтобы решить проблему ошибки .the есть в xmlpath и DLLPathIntelliSense: значение типа «void *» не может быть назначено сущности типа «char *» 16

void fmuLoad() { 
    char* fmuPath; 
char tmpPath[1000]="W:\\Prajwal\\GM_FMU_EXTRACT\\"; 
char* xmlPath; 
char* dllPath; 
const char *modelId; 
FMU fmu; 

fmuUnzip(); 
// parse tmpPath\modelDescription.xml 
xmlPath = calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1); 
sprintf(xmlPath, "%s%s", tmpPath, XML_FILE); 
fmu.modelDescription = parse(xmlPath); 
free(xmlPath); 
if (!fmu.modelDescription) exit(EXIT_FAILURE); 
//printf(fmu.modelDescription); 
#ifdef FMI_COSIMULATION 
modelId = getAttributeValue((Element*)getCoSimulation(fmu.modelDescription),att_modelIdentifier); 

//#else // FMI_MODEL_EXCHANGE 
// modelId = getAttributeValue((Element *)getModelExchange(fmu.modelDescription), att_modelIdentifier); 
#endif 
// load the FMU dll 
dllPath = calloc(sizeof(char), strlen(tmpPath) + strlen(DLL_DIR) + strlen(modelId) + strlen(".dll") + 1); 
sprintf(dllPath, "%s%s%s.dll", tmpPath, DLL_DIR, modelId); 
if (!loadDll(dllPath, &fmu)) { 
    exit(EXIT_FAILURE); 
} 
// free(dllPath); 
// free(fmuPath); 
// free(tmpPath); 

} 
+0

не функция, извините, но вы можете увидеть dllPath = calloc ** там отображается ошибка – PrajwalBhat

ответ

0

в C++, литая требуется присвоить указатель недействительным.

xmlPath = (char*)calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1); 

Или, используя C++ стиль:

xmlPath = static_cast<char*>(calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1)); 

Конечно, нужно действительно вопрос, почему вы используете старые функции библиотеки C, как calloc вообще. Если вы на самом деле компилируете программу на C, попробуйте сообщить своему компилятору, что это C, а не C++. Тогда кастинг не нужен.

0
static_cast<char*>(calloc(sizeof(char), strlen(tmpPath) + strlen(DLL_DIR) + strlen(modelId) + strlen(".dll") + 1)); 

возвращение типа calloc недействителен *. Вы должны явно указать результат calloc.