I ran brew install allegro on OSX while following this tutorial.

My code looks like this:

include <allegro.h>

int main(void) { 
  if (allegro_init() != 0)
     return 1;

  /* set up the keyboard handler */

  /* set a graphics mode sized 320x200 */
  if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
     if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
   allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
   return 1;

  /* set the color palette */

  /* clear the screen to white */
  clear_to_color(screen, makecol(255, 255, 255));

  /* you don't need to do this, but on some platforms (eg. Windows) things
   * will be drawn more quickly if you always acquire the screen before
   * trying to draw onto it.

  /* write some text to the screen with black letters and transparent background */
  textout_centre_ex(screen, font, "Hello, world!", SCREEN_W/2, SCREEN_H/2, makecol(0,0,0), -1);

  /* you must always release bitmaps before calling any input functions */

  /* wait for a keypress */

  return 0;

And I get these error messages:

1.c:1:1: error: unknown type name 'include'
include <allegro.h>
1.c:1:9: error: expected identifier or '('
include <allegro.h>
2 errors generated.
make: *** [1] Error 1
  • \$\begingroup\$ Try stackoverflow.com. This is not a game-programming question. \$\endgroup\$ – Almo Mar 10 '17 at 4:23
  • \$\begingroup\$ Somehow setting up tools is not a game programming question. \$\endgroup\$ – user333866 Mar 10 '17 at 13:49
  • \$\begingroup\$ Is Allegro a game-specific technology? \$\endgroup\$ – Almo Mar 10 '17 at 20:01
  • \$\begingroup\$ "Allegro is a software library for video game development.[2][3][4] The functionality of the library includes support for basic 2D graphics, image manipulation, text output, audio output, MIDI music, input and timers, as well as additional routines for fixed-point and floating-point matrix arithmetic, Unicode strings, file system access, file manipulation, data files, and 3D graphics." en.wikipedia.org/wiki/Allegro_(software) \$\endgroup\$ – user333866 Mar 11 '17 at 2:02

include <allegro.h>

This isn't valid; preprocessor directives start with a #. You probably meant to be typing #include <allegro.h>

Your error indicates this:

1.c:1:1: error: unknown type name 'include' include <allegro.h>

You can read this is the compiler reading include as a type, but there's no type named include that it knows about so it complains. This should make you question why the compiler thinks include is a type, because you should know you're trying to use the preprocessor to paste in the content of the Allego header file. Not name a type.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.