Skip to content

Fix MSVC-specific syntax issues#232

Open
ZHBHFUT wants to merge 1 commit intocburstedde:masterfrom
ZHBHFUT:master
Open

Fix MSVC-specific syntax issues#232
ZHBHFUT wants to merge 1 commit intocburstedde:masterfrom
ZHBHFUT:master

Conversation

@ZHBHFUT
Copy link
Contributor

@ZHBHFUT ZHBHFUT commented Oct 9, 2025

Fix MSVC-specific syntax issues

Proposed changes:

  1. noreturn Function Declarations

    • Modified noreturn function declarations to be compatible with MSVC compiler
    • Added platform-specific macros for proper cross-compilation support
  2. printf-style Format String Validation

    • Improved format string checking for printf-style functions
    • Added MSVC-compatible format specifiers where needed
  3. Improved aligned memory allocation and free

    • Use _aligned_malloc, _aligned_free, and _aligned_realloc on Windows.​​
  4. Windows Sleep Implementation

    • Added macro definitions in pthread.c for sleep functionality
    • Implemented Windows platform support using Sleep() API

These changes enable successful compilation on Windows using MSVC without requiring MinGW or clang-cl toolchains, while maintaining compatibility with other platforms.

Windows Build Instructions

To compile on Windows with MSVC:

  1. Generate VS solution using CMake:
cmake -G "Visual Studio 17 2022" -A x64
  1. Open the generated solution in Visual Studio and add code before the defination of struct sc_camera in sc_camera.h (cburstedde said this will be fiexd in the future 😄):
#ifdef near
#undef near
#endif
#ifdef far
#undef far
#endif
  1. Build as normal

@cburstedde
Copy link
Owner

Thanks! These platform-independent macros are long needed.
I'd like to include this. They just throw off our scindent script.
I know that GNU indent is not 100% capable, so we would not expect it to be correct in all cases. But maybe there's a way to have it produce at least a mostly reasonable indentation on say sc.h?

We might need to find another solution eventually, but right now I'd value any kind of fiddling, possibly irrational to us but helping indent, that reduces the diff after scindent.

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.

2 participants