Skip to content

Build fails when __SSE2__ is defined on msvc #2864

Closed

Description

@maxbachmann

E.g. simdjson_really_inline std::size_t scan_key_length(const char* p) noexcept { fails to compile on msvc with __SSE2__ defined since __builtin_ctz doesn't exist

I am not familiar enough with this code to know if it should just always be disabled on msvc or if it should use a wrapper function like

simdjson_fastfloat_really_inline SIMDJSON_FASTFLOAT_CONSTEXPR20 int
countr_zero_32(uint32_t input_num) {
  if (cpp20_and_in_constexpr()) {
    return countr_zero_generic_32(input_num);
  }
#ifdef SIMDJSON_FASTFLOAT_VISUAL_STUDIO
  unsigned long trailing_zero = 0;
  if (_BitScanForward(&trailing_zero, input_num)) {
    return static_cast<int>(trailing_zero);
  }
  return 32;
#else
  return input_num == 0 ? 32 : __builtin_ctz(input_num);
#endif
}

Activity

  1. lemire commented on Sep 17, 2026

    @lemire
    Member

    Visual studio does not define __SSE2__.

    You are not allowed to define __SSE2__.

    Any identifier that contains __ anywhere, or that starts with _ followed by an uppercase letter, is reserved

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions