Language: C

#define UTIL_SWAP(x, y)                                                                                                                    \
  do {                                                                                                                                     \
    typeof(x) _a = x;                                                                                                                      \
    x = y;                                                                                                                                 \
    y = _a;                                                                                                                                \
  } while (0)

uint32_t selection_sort(int32_t buf[], size_t size)
{
  uint32_t count = 0;

  uint32_t i;
  for (i = 0; i < size; i++) {
    uint32_t min_idx = i;
    uint32_t j;
    for (j = i + 1; j < size; j++) {
      if (buf[j] < buf[min_idx]) {
        min_idx = j;
      }
    }

    if (i != min_idx) {
      UTIL_SWAP(buf[i], buf[min_idx]);
      count++;
    }
  }

  return count;
}

#if !defined(TEST)
int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);
  int32_t buf[BUF_SIZE];
  uint32_t i;
  for (i = 0; i < num; i++) {
    scanf("%d", &buf[i]);
  }

  uint32_t count = selection_sort(buf, num);

  UTIL_PRINT_ARRAY(buf, num);
  printf("%d", count);

  return 0;
}

Compiler output:
main.c:8:1: error: unknown type name 'uint32_t'
    8 | uint32_t selection_sort(int32_t buf[], size_t size)
      | ^~~~~~~~
main.c:1:1: note: 'uint32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
  +++ |+#include <stdint.h>
    1 | #define UTIL_SWAP(x, y)                                                                                                                    \
main.c:8:25: error: unknown type name 'int32_t'
    8 | uint32_t selection_sort(int32_t buf[], size_t size)
      |                         ^~~~~~~
main.c:8:25: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:8:40: error: unknown type name 'size_t'
    8 | uint32_t selection_sort(int32_t buf[], size_t size)
      |                                        ^~~~~~
main.c:1:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
  +++ |+#include <stddef.h>
    1 | #define UTIL_SWAP(x, y)                                                                                                                    \
main.c:32:1: error: unknown type name 'int32_t'
   32 | int32_t main(void)
      | ^~~~~~~
main.c:32:1: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c: In function 'main':
main.c:34:3: error: unknown type name 'int32_t'
   34 |   int32_t num;
      |   ^~~~~~~
main.c:34:3: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:35:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   35 |   scanf("%d", &num);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define UTIL_SWAP(x, y)                                                                                                                    \
main.c:35:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   35 |   scanf("%d", &num);
      |   ^~~~~
main.c:35:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:36:3: error: unknown type name 'int32_t'
   36 |   int32_t buf[BUF_SIZE];
      |   ^~~~~~~
main.c:36:3: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:36:15: error: 'BUF_SIZE' undeclared (first use in this function)
   36 |   int32_t buf[BUF_SIZE];
      |               ^~~~~~~~
main.c:36:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:37:3: error: unknown type name 'uint32_t'
   37 |   uint32_t i;
      |   ^~~~~~~~
main.c:37:3: note: 'uint32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:42:3: error: unknown type name 'uint32_t'
   42 |   uint32_t count = selection_sort(buf, num);
      |   ^~~~~~~~
main.c:42:3: note: 'uint32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:42:20: error: implicit declaration of function 'selection_sort' [-Wimplicit-function-declaration]
   42 |   uint32_t count = selection_sort(buf, num);
      |                    ^~~~~~~~~~~~~~
main.c:44:3: error: implicit declaration of function 'UTIL_PRINT_ARRAY' [-Wimplicit-function-declaration]
   44 |   UTIL_PRINT_ARRAY(buf, num);
      |   ^~~~~~~~~~~~~~~~
main.c:45:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   45 |   printf("%d", count);
      |   ^~~~~~
main.c:45:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:45:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:45:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: At top level:
main.c:31: error: unterminated #if
   31 | #if !defined(TEST)