erkyrath/glulxe

main.c now contains code invalid under C90

Closed this issue · 1 comments

From main.c:

void fatal_error_handler(char *str, char *arg, int useval, glsi32 val)
{
  /* If the debugger is compiled in, send the error message to the debug
     console. This may also block for debug commands, depending on 
     preferences. */
  debugger_handle_crash(str);
  winid_t win = get_error_win();

The trouble is of course that declaring a variable not at the start of a scope block isn't legal in C90, though it is in C99, and recent versions of GCC accept it anyway. There's something to be said for just insisting on C99, though in that case the README should mention it and the Makefile pass -std=c99 to GCC.

I just took the simplest approach and changed the code to

void fatal_error_handler(char *str, char *arg, int useval, glsi32 val)
{
  /* If the debugger is compiled in, send the error message to the debug
     console. This may also block for debug commands, depending on 
     preferences. */
  winid_t win;
  debugger_handle_crash(str);
  win = get_error_win();

There are probably more of these. I tried compiling with clang's -Wdeclaration-after-statement argument, but it doesn't seem to catch them.