Skip to content

Add native Windows support, CMake improvements, and test fixtures - #17

Open
Schryzon wants to merge 1 commit into
mlafeldt:mainfrom
Schryzon:feat/windows-support
Open

Add native Windows support, CMake improvements, and test fixtures#17
Schryzon wants to merge 1 commit into
mlafeldt:mainfrom
Schryzon:feat/windows-support

Conversation

@Schryzon

@Schryzon Schryzon commented Jul 31, 2026

Copy link
Copy Markdown

Summary

This PR adds full native Windows compatibility to cb2util so it can be compiled and run seamlessly using CMake (MSVC / MinGW), GCC / Make, and Zig without requiring POSIX system headers or curl during compilation.

Key Changes

  • Standalone include/elf.h: Included 32-bit ELF header definitions (Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr) so pcb.c compiles out of the box on non-Linux platforms without fetching via curl.
  • Portable getopt implementation: Added lightweight include/getopt.h and getopt.c for compilers lacking POSIX <getopt.h> (e.g. MSVC).
  • C99 Compatibility: Replaced GCC zero-length array extensions (uint8_t data[0]) with standard C99 flexible array members (uint8_t data[]) in pcb.c, cbc.c, and cheats.c.
  • CMake & Makefile Updates: Added CMakeLists.txt, added automatic FetchContent fallback for zlib when system zlib is absent, and updated Makefile for Windows executable targets (cb2util.exe).
  • Test Suite Updates: Added additional CBC test fixtures into test/cbc/.
  • Documentation: Updated README.md with Windows installation and build instructions.

Verification

  • Tested compilation on Windows with MSVC 19.44 (Visual Studio 2022) via CMake.
  • Tested compilation on Windows with MinGW GCC under strict flags (-Wall -Werror).
  • Verified execution of cb2util.exe on sample files, passing verification, extraction, and decryption tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant