Skip to content
kshkuPublic

About

Core foundation for Sn libraries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

Repository files navigation

SnCore

Core foundation for Sn* projects. Provides platform detection, utility macros, API export/import helpers, common callback type definitions, and cross-platform UTF-8/UTF-16 conversion utilities.

The Sn Project

The Sn Project is a collection of modular C libraries designed to provide reusable building blocks for native software development. Each library focuses on a specific area while sharing consistent design principles and API conventions. The project originated from an experimental cross-platform game engine, with reusable components gradually extracted into standalone libraries as the repeated-need pattern emerged.

Library Description
SnCore Core foundation for Sn libraries
SnMemory Memory allocators and virtual memory abstraction
SnThreads Thread and synchronization abstraction library
SnLogger Logging library with synchronous and asynchronous modes
SnPlatform Platform abstraction layer
SnContainer Generic container library
SnFile File system and I/O utilities
SnEnv Environment variable and process environment utilities
SnDL Dynamic loading library for shared libraries
SnTime Time and clock utilities
SnTracer Tracing library
SnTest Unit testing framework
SnNetwork Socket and networking abstraction library

Contents

  • platform.h — Compiler, OS, architecture, and endian detection
  • defines.h — Utility macros (inline, assert, min/max, bit flags, alignment, stringify, byte arrays)
  • api_common.h — Shared SN_API_HELPER_EXPORT / SN_API_HELPER_IMPORT macros
  • types.h — Common callback type definitions (SnMemoryAllocateFn, SnLockFn, SnTimeNowFn, etc.)
  • utf8.h — UTF-8 ↔ UTF-16 conversion functions (Windows: real conversion; other platforms: stubs)

Usage

#include <sncore/platform.h>
#include <sncore/defines.h>
#include <stdio.h>

int main(void) {
#if defined(SN_OS_LINUX)
    printf("Running on Linux\n");
#elif defined(SN_OS_WINDOWS)
    printf("Running on Windows\n");
#endif

    // Alignment helper
    uint64_t unaligned = 0x1003;
    uint64_t aligned = SN_GET_ALIGNED(unaligned, 8);
    printf("Aligned: %llu\n", (unsigned long long)aligned);  // 0x1008

    return 0;
}

Adding to your project

include(FetchContent)
FetchContent_Declare(sncore
    GIT_REPOSITORY https://github.com/kshku/SnCore.git
    GIT_TAG <tag>  # e.g., v0.1.0
)
FetchContent_MakeAvailable(sncore)

target_link_libraries(myapp PRIVATE sncore)

Dependencies

  • None. SnCore has no external dependencies.

About

Core foundation for Sn libraries

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages