Update: move the declarations out of the ifdef

This commit is contained in:
Rodolfo Barcelli Jo 2026-01-16 17:47:49 +08:00
parent 218546d26f
commit 6d7d0bb26a
4 changed files with 26 additions and 9 deletions

24
becs.h
View file

@ -1,29 +1,37 @@
#ifndef BECS_H #ifndef BECS_H
#define BECS_H #define BECS_H
#ifdef BECS_IMPLEMENTATION
#include <stdint.h> #include <stdint.h>
typedef struct BECS_ComponentArray { typedef struct BECS_ComponentArray BECS_ComponentArray;
typedef struct BECS_Properties BECS_Properties;
typedef struct BECS_ECS BECS_ECS;
size_t BECS_GetMinMemorySize(BECS_Properties props);
BECS_ECS *BECS_Init(void *memory, size_t size, BECS_Properties *props);
int32_t BECS_AddComponent(BECS_ECS *ecs, uint32_t entityID, uint64_t componentBitMask, void *component);
#ifdef BECS_IMPLEMENTATION
struct BECS_ComponentArray {
uint32_t lastEntityAdded; uint32_t lastEntityAdded;
size_t unitSize; size_t unitSize;
uint32_t length; uint32_t length;
uint32_t capacity; uint32_t capacity;
void *array; void *array;
} BECS_ComponentArray; };
typedef struct BECS_Properties { struct BECS_Properties {
uint32_t maxEntities; uint32_t maxEntities;
uint32_t numComponents; uint32_t numComponents;
size_t *componentSizes; size_t *componentSizes;
} BECS_Properties; };
typedef struct BECS_ECS { struct BECS_ECS {
uint64_t *bitMasks; uint64_t *bitMasks;
BECS_Properties props; BECS_Properties props;
BECS_ComponentArray *componentSets; BECS_ComponentArray *componentSets;
} BECS_ECS; };
size_t BECS_GetMinMemorySize size_t BECS_GetMinMemorySize
(BECS_Properties props) (BECS_Properties props)

View file

@ -1 +1,8 @@
@echo off
REM Build Script for BECS REM Build Script for BECS
mkdir build
pushd ".\build"
cl /GR- /Oi /EHa- /MTd /Zi "..\test\main.c"
popd

View file

@ -1 +1,3 @@
# Build script for BECS # Build script for BECS
echo "Build Script not written"

View file

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#define BECS_IMPLEMENTATION #define BECS_IMPLEMENTATION
#include "becs.h" #include "../becs.h"
typedef struct compA { typedef struct compA {
uint32_t thing; uint32_t thing;