Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_init crash

This thread is locked; no one can reply to it. rss feed Print
al_init crash
William Labbett
Member #4,486
March 2004
avatar

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
Second in Command
February 2005
avatar

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;

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

William Labbett
Member #4,486
March 2004
avatar

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.

Go to: