#pragma once

#include "version.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>

#ifdef __cplusplus
#define CG_BEGIN_DEFS extern "C" {
#define CG_END_DEFS   }
#else
#define CG_BEGIN_DEFS 
#define CG_END_DEFS
#endif


CG_BEGIN_DEFS


#ifndef UNUSED
# if __STDC_VERSION__ > 201710L // We are using C2X
#   define  UNUSED  [[maybe_unused]]
# else
#   define  UNUSED  __attribute__((unused))
# endif
#endif


#ifndef DEPRECATED
# if __STDC_VERSION__ > 201710L // We are using C2X
#   define  DEPRECATED  [[deprecated]]
# else
#   define  DEPRECATED  __attribute__((deprecated))
# endif
#endif

#ifndef ALIGNED
# define ALIGNED(N) __attribute__((aligned (N)))
#endif

#ifndef FORMAT_STR
# define F_FORMAT_STR(start, end) __attribute__((format (printf, start, end)))
#endif

#ifndef CLEANUP
# define CLEANUP(func) __attribute__((cleanup (func)))
#endif

#ifndef NOT_IMPLEMENTED
# define NOT_IMPLEMENTED {\
  err_print ("[%s:%i] Function %s is not implemented yet.", __FILE__, __LINE__ , __func__); \
  abort (); \
}
#endif


#ifndef IN
# define IN
#endif
#ifndef OUT
# define OUT
#endif


typedef enum SEEK_OFFSET {
  /** Beginning of file */
  SEEK_OFFSET_SET = SEEK_SET,

  /** Current position of the pointer */
  SEEK_OFFSET_CUR = SEEK_CUR,

  /** End of file */
  SEEK_OFFSET_END = SEEK_END,
} SEEK_OFFSET;




typedef char* str_t;

typedef void* ptr_t;

typedef int8_t byte;

#define auto __auto_type

CG_END_DEFS
