Reputation: 21
SO, I'm using the latest version and the latest version of Allegro, but on lines 6 and 12 I seem to have encountered some errors that are not yet clear to me. I am very new to C++ as well as Allegro, so any help would be very much appreciated.
For line 6 I have the error message: "expected identifier or '(' before string constant
For line 12, I have the error message: "'display' undeclared (first use in this function)
#include<allegro5/allegro.h>
#include<allegro5/allegro_native_dialog.h>
int main()
{
ALLEGRO_DISPLAY "display";
if(!al_init())
{
al_show_native_message_box(NULL, NULL, NULL, "Could not initialize Allegro 5", NULL, NULL);
}
display = al_create_display(800, 600);
if(!display)
{
al_show_native_message_box(NULL, NULL, NULL, "Could not create Allegro Window", NULL, NULL);
}
return 0;
}
Upvotes: 2
Views: 300
Reputation: 17903
Change line 6 to:
ALLEGRO_DISPLAY *display;
This line declares a variable named "display
" of type (pointer to) ALLEGRO_DISPLAY
. So line 12 should no longer cause an error.
Relevant documentation:
Upvotes: 1
Reputation: 7388
ALLEGRO_DISPLAY "display";
If you want to declare a variable of type ALLEGRO_DISPLAY
with the name display
, there should not be quotation marks.
But al_create_display
returns not a ALLEGRO_DISPLAY
, but a pointer to it, so the correct line would be:
ALLEGRO_DISPLAY* display;
Upvotes: 3