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
+1 -1
View File
@@ -156,7 +156,7 @@ stk_init();
### API Reference ### API Reference
#### Initialization #### Initialization
- `uint8_t stk_init(void)` - Initialize stk, returns `STK_INIT_SUCCESS` on success - `unsigned char stk_init(void)` - Initialize stk, returns `STK_INIT_SUCCESS` on success
- `void stk_shutdown(void)` - Shutdown and cleanup all modules - `void stk_shutdown(void)` - Shutdown and cleanup all modules
#### Runtime #### Runtime
+1 -2
View File
@@ -2,7 +2,6 @@
#define STK_H #define STK_H
#include "stk_version.h" #include "stk_version.h"
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
/* Buffers */ /* Buffers */
@@ -55,7 +54,7 @@ typedef enum {
STK_MOD_RELOAD STK_MOD_RELOAD
} stk_module_event_t; } stk_module_event_t;
uint8_t stk_init(void); unsigned char stk_init(void);
void stk_shutdown(void); void stk_shutdown(void);
size_t stk_module_count(void); size_t stk_module_count(void);
size_t stk_poll(void); size_t stk_poll(void);
+6 -7
View File
@@ -1,6 +1,5 @@
#include "platform.h" #include "platform.h"
#include "stk.h" #include "stk.h"
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -18,7 +17,7 @@ void **stk_handles = NULL;
stk_init_mod_func *stk_inits = NULL; stk_init_mod_func *stk_inits = NULL;
stk_shutdown_mod_func *stk_shutdowns = 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_init_name[STK_MOD_FUNC_NAME_BUFFER] = "stk_mod_init";
static char stk_mod_shutdown_name[STK_MOD_FUNC_NAME_BUFFER] = 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'; *dot = '\0';
} }
uint8_t is_valid_module_file(const char *filename) unsigned char is_valid_module_file(const char *filename)
{ {
const char *ext; const char *ext;
size_t name_len; size_t name_len;
@@ -72,7 +71,7 @@ int is_mod_loaded(const char *module_name)
return -1; return -1;
} }
uint8_t stk_module_load(const char *path, int index) unsigned char stk_module_load(const char *path, int index)
{ {
void *handle; void *handle;
stk_init_mod_func init_func; 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; 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; int result;
result = stk_module_load(path, index); result = stk_module_load(path, index);
@@ -155,7 +154,7 @@ void stk_module_free_memory(void)
stk_shutdowns = NULL; 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_module_ids = malloc(capacity * sizeof(*stk_module_ids));
stk_handles = malloc(capacity * sizeof(void *)); stk_handles = malloc(capacity * sizeof(void *));
@@ -170,7 +169,7 @@ uint8_t stk_module_init_memory(size_t capacity)
return STK_INIT_SUCCESS; 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; char (*new_module_ids)[STK_MOD_ID_BUFFER] = NULL;
void **new_handles = NULL; void **new_handles = NULL;
+5 -6
View File
@@ -1,5 +1,4 @@
#include "stk.h" #include "stk.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -29,10 +28,10 @@
#endif #endif
int is_mod_loaded(const char *module_name); 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); 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]; char full_path[STK_PATH_MAX_OS];
#ifdef _WIN32 #ifdef _WIN32
@@ -108,7 +107,7 @@ typedef struct {
} platform_watch_context_t; } platform_watch_context_t;
#endif #endif
uint8_t platform_mkdir(const char *path) unsigned char platform_mkdir(const char *path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return CreateDirectoryA(path, NULL) ? STK_PLATFORM_OPERATION_SUCCESS return CreateDirectoryA(path, NULL) ? STK_PLATFORM_OPERATION_SUCCESS
@@ -130,7 +129,7 @@ int platform_remove_file(const char *path)
#endif #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]; char buf[STK_PATH_MAX_OS];
int ret = STK_PLATFORM_FILE_COPY_ERROR; int ret = STK_PLATFORM_FILE_COPY_ERROR;
@@ -203,7 +202,7 @@ done:
return ret; return ret;
} }
uint8_t platform_remove_dir(const char *path) unsigned char platform_remove_dir(const char *path)
{ {
#ifdef _WIN32 #ifdef _WIN32
WIN32_FIND_DATAA fd; WIN32_FIND_DATAA fd;
+9 -10
View File
@@ -1,7 +1,6 @@
#include "stk.h" #include "stk.h"
#include "platform.h" #include "platform.h"
#include "stk_log.h" #include "stk_log.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -16,7 +15,7 @@ extern char (*stk_module_ids)[STK_MOD_ID_BUFFER];
extern size_t module_count; 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_mod_dir[STK_PATH_MAX_OS] = "mods";
static char stk_tmp_name[STK_MOD_ID_BUFFER] = ".tmp"; 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( stk_module_event_t *platform_directory_watch_check(
void *handle, char (**file_list)[STK_PATH_MAX], size_t *out_count, 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); char (*loaded_module_ids)[STK_MOD_ID_BUFFER], const size_t loaded_count);
uint8_t platform_mkdir(const char *path); unsigned char platform_mkdir(const char *path);
uint8_t platform_copy_file(const char *from, const char *to); unsigned char platform_copy_file(const char *from, const char *to);
uint8_t platform_remove_dir(const char *path); unsigned char platform_remove_dir(const char *path);
void extract_module_id(const char *path, char *out_id); void extract_module_id(const char *path, char *out_id);
int is_mod_loaded(const char *module_id); int is_mod_loaded(const char *module_id);
size_t stk_module_count(void); size_t stk_module_count(void);
uint8_t stk_module_load(const char *path, int index); unsigned char stk_module_load(const char *path, int index);
uint8_t stk_module_load_init(const char *path, int index); unsigned char stk_module_load_init(const char *path, int index);
uint8_t stk_module_init_memory(size_t capacity); unsigned char stk_module_init_memory(size_t capacity);
uint8_t stk_module_realloc_memory(size_t new_capacity); unsigned char stk_module_realloc_memory(size_t new_capacity);
void stk_module_unload(size_t index); void stk_module_unload(size_t index);
void stk_module_unload_all(void); 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; char (*files)[STK_PATH_MAX] = NULL;
size_t file_count, i, successful_loads = 0; size_t file_count, i, successful_loads = 0;
+5 -4
View File
@@ -31,8 +31,8 @@ void inthand(int signum)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
uint8_t init_result; unsigned char init_result;
uint64_t iterations = 0; size_t iterations = 0;
printf("stk test - CTRL+C to exit\n"); printf("stk test - CTRL+C to exit\n");
@@ -55,12 +55,13 @@ int main(int argc, char **argv)
while (!stop) { while (!stop) {
size_t events = stk_poll(); size_t events = stk_poll();
if (events > 0) if (events > 0)
printf("Poll: %lu module event(s) detected\n", (unsigned long) events); printf("Poll: %lu module event(s) detected\n",
(unsigned long)events);
iterations++; iterations++;
if (iterations % 5 == 0) { if (iterations % 5 == 0) {
printf("Still running... (iteration %lu)\n", printf("Still running... (iteration %lu)\n",
(unsigned long) iterations); (unsigned long)iterations);
} }
#ifdef _WIN32 #ifdef _WIN32
Sleep(1000); Sleep(1000);