Language: C

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

struct stack_tag {
  int32_t *data;
  size_t max_len;
  size_t size;
};

static bool check_is_null(const void *const p)
{
  if (p == NULL) {
    return true;
  }

  return false;
}

stack_t *stack_create(const size_t len)
{
  int32_t *data = (int32_t *)malloc(sizeof(int32_t) * len);
  stack_t *stack = (stack_t *)malloc(sizeof(stack_t));

  if (check_is_null(data) || check_is_null(stack)) {
    perror("memory is full\n");
    exit(1);
  }

  stack->data = data;
  stack->size = 0;
  stack->max_len = len;
  return stack;
}

void stack_destroy(stack_t *const stack)
{
  if (stack != NULL) {
    free(stack->data);
    free(stack);
  }
}

size_t stack_get_size(const stack_t *const stack)
{
  if (check_is_null(stack)) {
    return 0;
  }

  return stack->size;
}

bool stack_push(stack_t *const stack, const int32_t data)
{
  if (check_is_null(stack)) {
    return false;
  }

  if (stack->max_len <= stack->size) {
    return false;
  }

  stack->data[stack->size] = data;
  stack->size++;
  return true;
}

bool stack_pop(stack_t *const stack, int32_t *const data)
{
  if (check_is_null(stack)) {
    return false;
  }

  if (stack->size < 1) {
    return false;
  }

  stack->size--;
  *data = stack->data[stack->size];

  return true;
}

#if !defined(TEST)
#define STACK_SIZE 256
#define BUF_SIZE 128

static int32_t stack_pop_with_check(stack_t *const stack)
{
  int32_t data;
  bool ret = stack_pop(stack, &data);
  if (!ret) {
    perror("stack is full");
    exit(1);
  }

  return data;
}

static int32_t stack_push_with_check(stack_t *const stack, int32_t data)
{
  bool ret = stack_push(stack, data);
  if (!ret) {
    perror("stack is full\n");
    exit(1);
  }

  return data;
}

int32_t main(void)
{
  char str[BUF_SIZE];

  stack_t *s = stack_create(STACK_SIZE);

  while (scanf("%s", str)) {
    if (str[0] == '-') {
      int32_t a = stack_pop_with_check(s);
      int32_t b = stack_pop_with_check(s);
      stack_push_with_check(s, a - b);
    } else if (str[0] == '+') {
      int32_t a = stack_pop_with_check(s);
      int32_t b = stack_pop_with_check(s);
      stack_push_with_check(s, a + b);
    } else if (str[0] == '*') {
      int32_t a = stack_pop_with_check(s);
      int32_t b = stack_pop_with_check(s);
      stack_push_with_check(s, a * b);
    } else {
      bool ret = stack_push(s, atoi(str));
      if (!ret) goto err;
    }
  }

  stack_destroy(s);

  return 0;

err:
  perror("stack is full\n");
  exit(1);
}
#endif

Compiler output:
main.c:11:8: error: unknown type name 'bool'
   11 | static bool check_is_null(const void *const p)
      |        ^~~~
main.c:4:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    3 | #include <stdlib.h>
  +++ |+#include <stdbool.h>
    4 | 
main.c: In function 'check_is_null':
main.c:14:12: error: 'true' undeclared (first use in this function)
   14 |     return true;
      |            ^~~~
main.c:14:12: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:14:12: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:10: error: 'false' undeclared (first use in this function)
   17 |   return false;
      |          ^~~~~
main.c:17:10: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: At top level:
main.c:20:1: error: unknown type name 'stack_t'
   20 | stack_t *stack_create(const size_t len)
      | ^~~~~~~
main.c: In function 'stack_create':
main.c:23:3: error: unknown type name 'stack_t'
   23 |   stack_t *stack = (stack_t *)malloc(sizeof(stack_t));
      |   ^~~~~~~
main.c:23:21: error: 'stack_t' undeclared (first use in this function); did you mean 'stack'?
   23 |   stack_t *stack = (stack_t *)malloc(sizeof(stack_t));
      |                     ^~~~~~~
      |                     stack
main.c:23:30: error: expected expression before ')' token
   23 |   stack_t *stack = (stack_t *)malloc(sizeof(stack_t));
      |                              ^
main.c:30:8: error: request for member 'data' in something not a structure or union
   30 |   stack->data = data;
      |        ^~
main.c:31:8: error: request for member 'size' in something not a structure or union
   31 |   stack->size = 0;
      |        ^~
main.c:32:8: error: request for member 'max_len' in something not a structure or union
   32 |   stack->max_len = len;
      |        ^~
main.c: At top level:
main.c:36:20: error: unknown type name 'stack_t'
   36 | void stack_destroy(stack_t *const stack)
      |                    ^~~~~~~
main.c:44:29: error: unknown type name 'stack_t'
   44 | size_t stack_get_size(const stack_t *const stack)
      |                             ^~~~~~~
main.c: In function 'stack_get_size':
main.c:50:15: error: request for member 'size' in something not a structure or union
   50 |   return stack->size;
      |               ^~
main.c: At top level:
main.c:53:1: error: unknown type name 'bool'
   53 | bool stack_push(stack_t *const stack, const int32_t data)
      | ^~~~
main.c:53:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:53:17: error: unknown type name 'stack_t'
   53 | bool stack_push(stack_t *const stack, const int32_t data)
      |                 ^~~~~~~
main.c:68:1: error: unknown type name 'bool'
   68 | bool stack_pop(stack_t *const stack, int32_t *const data)
      | ^~~~
main.c:68:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:68:16: error: unknown type name 'stack_t'
   68 | bool stack_pop(stack_t *const stack, int32_t *const data)
      |                ^~~~~~~
main.c:88:37: error: unknown type name 'stack_t'
   88 | static int32_t stack_pop_with_check(stack_t *const stack)
      |                                     ^~~~~~~
main.c:100:38: error: unknown type name 'stack_t'
  100 | static int32_t stack_push_with_check(stack_t *const stack, int32_t data)
      |                                      ^~~~~~~
main.c: In function 'main':
main.c:115:3: error: unknown type name 'stack_t'
  115 |   stack_t *s = stack_create(STACK_SIZE);
      |   ^~~~~~~
main.c:119:19: error: implicit declaration of function 'stack_pop_with_check' [-Wimplicit-function-declaration]
  119 |       int32_t a = stack_pop_with_check(s);
      |                   ^~~~~~~~~~~~~~~~~~~~
main.c:121:7: error: implicit declaration of function 'stack_push_with_check' [-Wimplicit-function-declaration]
  121 |       stack_push_with_check(s, a - b);
      |       ^~~~~~~~~~~~~~~~~~~~~
main.c:131:7: error: unknown type name 'bool'
  131 |       bool ret = stack_push(s, atoi(str));
      |       ^~~~
main.c:131:7: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:131:18: error: implicit declaration of function 'stack_push' [-Wimplicit-function-declaration]
  131 |       bool ret = stack_push(s, atoi(str));
      |                  ^~~~~~~~~~
main.c:136:3: error: implicit declaration of function 'stack_destroy' [-Wimplicit-function-declaration]
  136 |   stack_destroy(s);
      |   ^~~~~~~~~~~~~