cc_args=('-O2' '-Wall' '-Wextra' '-I..')
if [ "$OS" == "Windows_NT" ] ; then
  cc_args_x=('-Wl,--stack=256000000')
elif [ "`uname -o`" == 'GNU/Linux' ] ; then
  ulimit -s unlimited
fi

function compile_cpp
{
  echo "Compile $1 to $2"
  if ! [ -e $2 ] ; then
    echo "  Do it. Compile flags: a = ${cc_args[@]}, b = ${cc_args_x[@]}"
    g++ "${cc_args[@]}" "${cc_args_x[@]}" $1 -o $2 || finish "compile: FAILED"
  else
    echo "  nothing to do"
  fi
}

function compile 
{
  compile_cpp $1.cpp $1.exe
}

function finish
{
  echo $*
  exit 1
}
