Allegro Error: 'Bool' undeclared (HELP)

I'm following a tutorial on how too initialize Allegro for a simple game. but i'm receiving error messages on line 12. Can someone please help me out.



Error Messages:
In function `_mangled_main':
`bool' undeclared (first use in this function)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <allegro.h>
int main()
{
    /* Initialization */
    allegro_init();
    install_keyboard();
    install_timer();
    install_mouse();
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, 0 );
    set_color_depth( 16 );
    
    bool fullscreen = false;
    
    if ( fullscreen == true )   // For fullscreen 
        set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
    else                        // For windowed 
        set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
    BITMAP *buffer = create_bitmap( 640, 480 );
    /* End Initialization */
    /* Game loop and such would go here */
    while ( !key[KEY_ESC] )
    {
          rectfill( buffer, 0, 0,
          640, 480
          makecol(255, 0, 0 ) );
    /* Draw functions */
    blit( buffer, screen, 0, 0, 0, 0, 640, 480 );
    clear_bitmap( buffer );
    }
    
    /* Free memory afterwards! */
    destroy_bitmap( buffer );
    
    return 0;
}
END_OF_MAIN();
Are you compiling as C or C++?
Not exactly sure. The source files are in C though.

EDIT: Im compiling in C++, I just checked
Last edited on
EDIT: Im compiling in C++, I just checked


Just how sure are you? bool exists in C++ and not in C, and the error you're getting is exactly what you'd see if you were compiling it as C.

Does the following compile?

1
2
3
4
5
int main()
{
bool fullscreen = false;
return 0;
}

Last edited on
Topic archived. No new replies allowed.