fix(core)!: enforce strict C89 compliance

BREAKING CHANGE: Public API now uses unsigned char instead of uint8_t

- Remove stdint.h dependency (C99 feature, not C89, I am a fucking idiot)
- Replace uint8_t with unsigned char throughout codebase
- Affects stk_init() return type and internal functions
- Corrects unintended C99 dependency, restoring intended C89 compliance
This commit is contained in:
2026-02-14 11:41:41 +01:00
parent fb0d8adb8f
commit bcb1795218
6 changed files with 27 additions and 30 deletions
+6 -7
View File
@@ -1,6 +1,5 @@
#include "platform.h"
#include "stk.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -18,7 +17,7 @@ void **stk_handles = NULL;
stk_init_mod_func *stk_inits = NULL;
stk_shutdown_mod_func *stk_shutdowns = NULL;
extern uint8_t stk_initialized;
extern unsigned char stk_initialized;
static char stk_mod_init_name[STK_MOD_FUNC_NAME_BUFFER] = "stk_mod_init";
static char stk_mod_shutdown_name[STK_MOD_FUNC_NAME_BUFFER] =
@@ -43,7 +42,7 @@ void extract_module_id(const char *path, char *out_id)
*dot = '\0';
}
uint8_t is_valid_module_file(const char *filename)
unsigned char is_valid_module_file(const char *filename)
{
const char *ext;
size_t name_len;
@@ -72,7 +71,7 @@ int is_mod_loaded(const char *module_name)
return -1;
}
uint8_t stk_module_load(const char *path, int index)
unsigned char stk_module_load(const char *path, int index)
{
void *handle;
stk_init_mod_func init_func;
@@ -121,7 +120,7 @@ uint8_t stk_module_load(const char *path, int index)
return STK_MOD_INIT_SUCCESS;
}
uint8_t stk_module_load_init(const char *path, int index)
unsigned char stk_module_load_init(const char *path, int index)
{
int result;
result = stk_module_load(path, index);
@@ -155,7 +154,7 @@ void stk_module_free_memory(void)
stk_shutdowns = NULL;
}
uint8_t stk_module_init_memory(size_t capacity)
unsigned char stk_module_init_memory(size_t capacity)
{
stk_module_ids = malloc(capacity * sizeof(*stk_module_ids));
stk_handles = malloc(capacity * sizeof(void *));
@@ -170,7 +169,7 @@ uint8_t stk_module_init_memory(size_t capacity)
return STK_INIT_SUCCESS;
}
uint8_t stk_module_realloc_memory(size_t new_capacity)
unsigned char stk_module_realloc_memory(size_t new_capacity)
{
char (*new_module_ids)[STK_MOD_ID_BUFFER] = NULL;
void **new_handles = NULL;
+5 -6
View File
@@ -1,5 +1,4 @@
#include "stk.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,10 +28,10 @@
#endif
int is_mod_loaded(const char *module_name);
uint8_t is_valid_module_file(const char *filename);
unsigned char is_valid_module_file(const char *filename);
void extract_module_id(const char *path, char *out_id);
static uint8_t is_file_ready(const char *dir_path, const char *filename)
static unsigned char is_file_ready(const char *dir_path, const char *filename)
{
char full_path[STK_PATH_MAX_OS];
#ifdef _WIN32
@@ -108,7 +107,7 @@ typedef struct {
} platform_watch_context_t;
#endif
uint8_t platform_mkdir(const char *path)
unsigned char platform_mkdir(const char *path)
{
#ifdef _WIN32
return CreateDirectoryA(path, NULL) ? STK_PLATFORM_OPERATION_SUCCESS
@@ -130,7 +129,7 @@ int platform_remove_file(const char *path)
#endif
}
uint8_t platform_copy_file(const char *from, const char *to)
unsigned char platform_copy_file(const char *from, const char *to)
{
char buf[STK_PATH_MAX_OS];
int ret = STK_PLATFORM_FILE_COPY_ERROR;
@@ -203,7 +202,7 @@ done:
return ret;
}
uint8_t platform_remove_dir(const char *path)
unsigned char platform_remove_dir(const char *path)
{
#ifdef _WIN32
WIN32_FIND_DATAA fd;
+9 -10
View File
@@ -1,7 +1,6 @@
#include "stk.h"
#include "platform.h"
#include "stk_log.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,7 +15,7 @@ extern char (*stk_module_ids)[STK_MOD_ID_BUFFER];
extern size_t module_count;
uint8_t stk_initialized = 0;
unsigned char stk_initialized = 0;
static char stk_mod_dir[STK_PATH_MAX_OS] = "mods";
static char stk_tmp_name[STK_MOD_ID_BUFFER] = ".tmp";
@@ -30,18 +29,18 @@ void platform_directory_watch_stop(void *handle);
stk_module_event_t *platform_directory_watch_check(
void *handle, char (**file_list)[STK_PATH_MAX], size_t *out_count,
char (*loaded_module_ids)[STK_MOD_ID_BUFFER], const size_t loaded_count);
uint8_t platform_mkdir(const char *path);
uint8_t platform_copy_file(const char *from, const char *to);
uint8_t platform_remove_dir(const char *path);
unsigned char platform_mkdir(const char *path);
unsigned char platform_copy_file(const char *from, const char *to);
unsigned char platform_remove_dir(const char *path);
void extract_module_id(const char *path, char *out_id);
int is_mod_loaded(const char *module_id);
size_t stk_module_count(void);
uint8_t stk_module_load(const char *path, int index);
uint8_t stk_module_load_init(const char *path, int index);
uint8_t stk_module_init_memory(size_t capacity);
uint8_t stk_module_realloc_memory(size_t new_capacity);
unsigned char stk_module_load(const char *path, int index);
unsigned char stk_module_load_init(const char *path, int index);
unsigned char stk_module_init_memory(size_t capacity);
unsigned char stk_module_realloc_memory(size_t new_capacity);
void stk_module_unload(size_t index);
void stk_module_unload_all(void);
@@ -70,7 +69,7 @@ static const char *stk_error_string(int error_code)
}
}
uint8_t stk_init(void)
unsigned char stk_init(void)
{
char (*files)[STK_PATH_MAX] = NULL;
size_t file_count, i, successful_loads = 0;