Managing error codes

The example below shows the use of error codes management functions:

BOOL DoSomething(void *Buffer, int Size)
{
  /* Check parameters */
  if(Size < 0)
  {
    /* Failure */
    stSetLastError(ERR_INVALID_PARAMETER);
    return FALSE;
  }

  /* Do something */
  /* ... */

  /* Success */
  return TRUE;
}

/* ... */

/* Somewhere in source code: */
if(!DoSomething((void *) &Buffer[4], Size - 4))
{
  printf("DoSomething function fail, error code: %i\n",
    (int) stGetLastError());
  return FALSE;
}

/* ... */
SpaceShadow documentation