Devil iluErrorString () вызывает нарушение прав доступа

Пожалуйста, посмотрите на результаты моего первого дня VC ++. Он содержит ошибку, о которой я знаю. Моя проблема в том, что дьявол выдает ошибку, как и должно быть, но попытка декодировать эту ошибку в строку с помощью iluErrorString () вызывает нарушение прав доступа …

#pragma comment(lib, "ILU.lib")
#pragma comment(lib, "ILUT.lib")

#include <iostream>
#include <conio.h>
#include <stdio.h>

#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>

using namespace std;

int main(){
FILE *myFile;
ILuint fileSize;
ILubyte *Lump;

ilInit();

ILuint ImageName; // The image name to return.
ilGenImages(1, &ImageName); // Grab a new image name.

ilBindImage(ImageName); //bind the image

myFile = fopen("C:/Documents and Settings/Bartjan/Desktop/c++ meuq/test/Debug/image.png", "r"); //open the file for reading
if (myFile != NULL){
fseek(myFile, 0, SEEK_END); //get file size
fileSize = ftell(myFile);

Lump = (ILubyte*)malloc(fileSize); //allocate mem
fseek(myFile, 0, SEEK_SET); //set the file pointer
fread(Lump, 1, fileSize, myFile); //read the entire file into mem

fclose(myFile);

ilLoadL(IL_PNG, Lump, fileSize);
free(Lump);
}

ilDeleteImages(1, &ImageName); //delete the image

ILenum error;
while ((error = ilGetError()) != IL_NO_ERROR) {
cout << error << ": " << iluErrorString(error);
}

_getch();
return 0;
}

Выдает ошибку 1285, означающую, что не понимает этого:

ilLoadL(IL_PNG, Lump, fileSize);

Это я в курсе. Проблема здесь:

cout << error << ": " << iluErrorString(error);

Это вызывает нарушение прав доступа, и я не могу понять, почему?

2

Решение

Эта проблема возникает, если вы не инициализировали ILU, как вы сделали для IL:

iluInit();
1

Другие решения

Это потому, что iluErrorString всегда возвращает 0, как и ilGetString.

0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector