al_init crash
William Labbett

Hi,

I get a crash, when I call al_init().

Hoaven't programmed for a long time. Is it something obvious?

Here's the code :

#SelectExpand
1class InitialisationClass 2{ 3 4 public: 5 6 7 uint32_t version; 8 int init_okay; 9 10 InitialisationClass(void) : init_okay(0), version(0) 11 { 12 ; 13 } 14 15 InitialisationClass(ofstream &log) 16 { 17 cout << "here 1.\n"; 18 if( al_install_system(ALLEGRO_VERSION_INT, atexit) == false) 19 { 20 21 log.write("Unable to install the allegro system.\n", 39); 22 return; 23 } 24 25 cout << "here 2.\n"; 26 27 if(al_init_ttf_addon() == false) 28 { 29 log.write("Unable to install true type font addon.\n", 41); 30 return; 31 } 32 33 init_okay = 1; 34 } 35 36 /* Constructor for when the log file couldn't be created. */ 37 38 InitialisationClass(int dummy) 39 { 40 cout << "Calling al_install_system().\n"; 41 if( al_init() == false) 42 { 43 cout << "here 10."; 44 return; 45 } 46 47 cout << "Called it.\n"; 48 49 if(al_init_ttf_addon() == false) 50 { 51 return; 52 } 53 54 init_okay = 1; 55 } 56 57 private: 58 59 int print_version_number(void) 60 { 61 ; 62 } 63 64 65 66 67 68 69 70 71 72 73 74}; 75/* END OF definition of SetUpClass. */

{"name":"609070","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21629f69fb135a7cbe87f4c06b1058d8.png","w":416,"h":156,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21629f69fb135a7cbe87f4c06b1058d8"}609070

Arthur Kalliokoski

I can't read what's in the image, but the console shows "here 1" but not "here 2"?

It worked fine in C just now.

  if( al_install_system(ALLEGRO_VERSION_INT, atexit) == false)
    printf("phooey\n");
  else
    printf("yay\n");
  return 0;

Edgar Reynaldo

You probably have a different version dll than the version your program was compiled with interfering or you have mis-matched headers. Delete old dlls and re-copy new ones. Use Dependency Walker if you need to.

William Labbett

Thanks Arthur,

I worked out what's wrong.

When I declared the instance of the InitialisationClass which this constructor is being called for, I didn't call the default constructor. i think this was causing the problem.

Thanks.

Thread #614847. Printed from Allegro.cc