Fix build failure on mswin (MSVC) - #34
Open
hsbt wants to merge 2 commits into
Open
Conversation
MSVC does not support C99 variable-length arrays, so `char buf[len]` in msgpack_packer_write_bignum_value fails with C2057/C2466/C2133. Use ALLOCV_N instead, which falls back to a GC-managed heap buffer and stays safe across rb_raise. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
unsigned long is 32-bit on Windows (LLP64), so rb_num2ulong raises RangeError for tags above 0xffffffff and the "Tagged" spec fails. cbor_encoder_write_head takes uint64_t; convert with rb_num2ull. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MSVC does not support C99 variable-length arrays, so
char buf[len]inmsgpack_packer_write_bignum_valuefails to compile on x64-mswin64 with C2057/C2466/C2133. This replaces the VLA withALLOCV_N, which allocates a GC-managed temporary buffer and stays safe acrossrb_raise.With the build fixed, the "Tagged" spec still failed on Windows because
unsigned longis 32-bit there andrb_num2ulongraisesRangeErrorfor tags above 0xffffffff.cbor_encoder_write_headtakesuint64_t, so tag values are now converted withrb_num2ull. Behavior on LP64 platforms is unchanged.Verified on
x64-mswin64_140(Ruby 4.0.5, MSVC 14.51) withgem buildandgem install, and the RSpec suite passes with 170 examples, 0 failures.