Skip to content

fix: make the public headers compile with MSVC - #252

Open
cruzzil wants to merge 1 commit into
asdf-format:mainfrom
cruzzil:msvc-headers
Open

fix: make the public headers compile with MSVC#252
cruzzil wants to merge 1 commit into
asdf-format:mainfrom
cruzzil:msvc-headers

Conversation

@cruzzil

@cruzzil cruzzil commented Sep 5, 2026

Copy link
Copy Markdown

Fixes #251.

  • asdf_value_find_ex and asdf_find_iter_init_ex take max_depth as ptrdiff_t instead of the POSIX-only ssize_t, which MSVC's CRT does not define. <sys/types.h> was included in asdf/value.h only for that type, so it is dropped; no other public header uses it.
  • The option flag bitmasks in asdf/emitter.h, asdf/parser.h and asdf/log.h use 1ULL instead of 1UL. This is not only a Windows issue: on any LLP64 target unsigned long is 32 bits, so ASDF_EMITTER_OPT_LAST = 1UL << 62 is undefined behaviour, and the accompanying 1UL << 63 static assertion has never tested what it reads as there.

No ABI change: ptrdiff_t and ssize_t are the same pointer-sized signed integer on every platform libasdf currently supports.

Built and ran the test suite on Linux/gcc; all tests pass.

Use ptrdiff_t instead of the POSIX-only ssize_t for the max_depth
parameter of asdf_value_find_ex and asdf_find_iter_init_ex, and build
the option flag bitmasks with 1ULL instead of 1UL, which overflows
where unsigned long is 32 bits.
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.

Public headers do not compile with MSVC: ssize_t, and 1UL << 63 on LLP64

1 participant