Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro in Headers

This thread is locked; no one can reply to it. rss feed Print
Allegro in Headers
SkaxCo
Member #8,323
February 2007

I'm working on my program when all of a sudden...it doesn't build. I mess around, and find out it can't include allegro.h in my header file BUT! its been working fine for ages. It also works in the main body of the program. It is really annoying...anyone know why it would work in main but not in a header?

kazzmir
Member #1,786
December 2001
avatar

post the error

SkaxCo
Member #8,323
February 2007

Now it isn't working in main() either...
alleg.lib is included.

Unhandled exception at 0x10028b32 in Dodge III.exe: 0xC0000005: Access violation reading location 0x0000001c.

kazzmir
Member #1,786
December 2001
avatar

You have a segfault or some other exception. This has nothing to do with including allegro.h in your game. You are using memory in an incorrect way or something similar.

SkaxCo
Member #8,323
February 2007

Hold on, I'll show you the code that is in the program:

1//============================================
2//Don't hit anything
3//SkaxCo Productions, 2007
4//============================================
5/*INCLUDES*/
6#include <allegro.h>
7/*FUNCTION PROTOTYPES*/
8void allegro_startup();
9int game();
10void game_setup();
11/*FUN-NESS*/
12BITMAP *buffy;
13int main(){
14 allegro_startup();
15 game_setup();
16 int cont = 1;
17 while(cont == 1){
18 cont = game();
19 }
20 return 0;
21}END_OF_MAIN()
22void allegro_startup(){
23 int ret;
24 allegro_init();
25 install_keyboard();
26 install_mouse();
27 install_timer();
28 set_color_depth(desktop_color_depth());
29 // XSize,Ysize
30 ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 510, 0, 0);
31 if (ret != 0){
32 allegro_message(allegro_error);
33 }
34}
35int game(){
36 while(!key[KEY_ESC]){
37 rest(20);
38 blit(buffy, screen, 0, 0, 0, 0, 640, 510);
39 }
40 return 1;
41}
42void game_setup(){
43 rectfill(buffy, 0, 0, SCREEN_W, SCREEN_H, makecol(64,64,64));
44 rectfill(buffy, 5, 5, 634, 475, makecol(220,220,220));
45 rectfill(buffy, 5, 485, 634, 505, makecol(128,256,200));
46}

X-G
Member #856
December 2000
avatar

buffy isn't created anywhere. :P

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

SkaxCo
Member #8,323
February 2007

/*FUN-NESS*/
BITMAP *buffy;

Oh! Yeah! In the header buffy = creat_bitm....

Now it returns:

Unhandled exception at 0x1002061b in Dodge III.exe: 0xC0000005: Access violation reading location 0x00000038.

THe only difference in code is:
BITMAP *buffy = create_bitmap(640,510);

X-G
Member #856
December 2000
avatar

... wait, what? In a header? No.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

SkaxCo
Member #8,323
February 2007

Nonono there is no header anymore.
But it still doesnt work.
OK: it works if I take out buffy. WHy?

Steve Terry
Member #1,989
March 2002
avatar

Quote:

OK: it works if I take out buffy. WHy?

... because she's a vampire slayer?

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

julian_boolean
Member #8,201
January 2007

Kinda ironic that the Wikipedia's featured article is Buffy the Vampire Slayer.

SkaxCo
Member #8,323
February 2007

...
buffy was a bitmap that I was going to use as a buffer.
WHen I don't create it, just take the line of code out, it runs fine.

Jonatan Hedborg
Member #4,886
July 2004
avatar

Where do you create your "buffy"?

If you change your code, specify what you have changed exactly (or even better, post it again, with the changes).

Go to: