Skip to content

replaced msvc __int64 to int64_t, updated Int64ToString and TryParseI…#1524

Open
smhussa22 wants to merge 1 commit intoMCLCE:mainfrom
smhussa22:int64-portability-fix
Open

replaced msvc __int64 to int64_t, updated Int64ToString and TryParseI…#1524
smhussa22 wants to merge 1 commit intoMCLCE:mainfrom
smhussa22:int64-portability-fix

Conversation

@smhussa22
Copy link
Copy Markdown

…nt64 to use int64_t instead

Description

Changed the use of MSVC-specific 64 bit integer type to C++ standard 64 bit integer type to increase compiler-portability, which is consistent with the rest of the codebase (see related issues).

Changes

Replaced uses of the MSVC __int64 to use int64_t from cstdint for portability reasons (this has been happening in other files in the repo as well).
Changed MSVC-specific conversion functions (TryParseInt64, Int64ToString) to reflect this change.

Previous Behavior

The file previously used __int64 which is MSVC-specific. Thus, two functions TryParseInt64 and Int64ToString also used __int64 parameters.

Root Cause

Use of MSVC's 64 bit integer type reduces portability when the C++ standard int64_t type could be used to fix this.
The change from MSVC __int64 to int64_t is being done in other parts of the codebase, so it is best to reflect this everywhere (see related issues).

New Behavior

The affected functions behave exactly as they did before, which is expected.

Fix Implementation

Int64ToString:

  • Removed the use _i64toa_s function which converts __int64 to a C-style string via a buffer. The function then returned this C-style string in a std::string constructor.
  • Instead used std::to_string directly on the new int64_t and returned that.

TryParseInt64:

  • Removed use of _strtoi64 and replaced with strtoll
  • Static cast the long long to int64_t.
  • Preserved the rest of the logic.

AI Use Disclosure

This code was written by myself without the use of any LLM/AI.

Related Issues

@smhussa22 smhussa22 force-pushed the int64-portability-fix branch from ec51697 to 7bcfedf Compare April 16, 2026 20:18
@codeHusky codeHusky self-assigned this Apr 17, 2026
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