Skip to content

fix(vc6): use unsigned __int64 and %I64X to support VC6 compiler in BitFlags.h#2759

Open
Okladnoj wants to merge 1 commit into
TheSuperHackers:mainfrom
Okladnoj:okji/fix-bitflags-vc6
Open

fix(vc6): use unsigned __int64 and %I64X to support VC6 compiler in BitFlags.h#2759
Okladnoj wants to merge 1 commit into
TheSuperHackers:mainfrom
Okladnoj:okji/fix-bitflags-vc6

Conversation

@Okladnoj
Copy link
Copy Markdown

Failure Logs at disable RETAIL_COMPATIBLE_CRC

1886: C:\VC6\VC6SP6\VC98\Bin\CL.EXE ... -c D:\a\GeneralsGameCode\GeneralsGameCode\GeneralsMD\Code\GameEngine\Source\GameLogic\Object\Object.cpp
1887: Object.cpp
1888: ##[error]D:\a\GeneralsGameCode\GeneralsGameCode\GeneralsMD\Code\GameEngine\Include\Common/BitFlags.h(312) : error C2632: 'long' followed by 'long' is illegal
1889:         D:\a\GeneralsGameCode\GeneralsGameCode\GeneralsMD\Code\GameEngine\Include\Common/BitFlags.h(304) : while compiling class-template member function 'class AsciiString __thiscall BitFlags<512>::toHexString(void) const'

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR fixes a VC6 compiler error ('long' followed by 'long' is illegal) in BitFlags<N>::toHexString() by replacing the C99 unsigned long long type and %llX printf specifier with their MSVC/Windows equivalents (UnsignedInt64 / %I64X). The fix is applied identically to both the Generals and GeneralsMD copies of BitFlags.h.

  • unsigned long longUnsignedInt64 (defined as uint64_t / unsigned __int64 in Core/Libraries/Include/Lib/BaseTypeCore.h), consistent with the project's type alias conventions.
  • %llX / %016llX%I64X / %016I64X, which is the correct MSVC CRT specifier for a 64-bit integer on VC6 and all later MSVC versions.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted fix limited to the toHexString() helper, and the new type and format specifier are correct for the MSVC/Windows-only build target this PR addresses.

Both changed files receive identical, self-consistent edits: swapping the non-VC6 unsigned long long literal type for the project's standard UnsignedInt64 alias (itself backed by uint64_t / unsigned __int64), and replacing %llX with %I64X which is the correct Windows CRT specifier for that type. The existing portability note about %I64X vs %llX for non-MSVC toolchains was already raised in a previous review and is a pre-existing trade-off, not a new defect introduced here.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/Common/BitFlags.h Replaces unsigned long long with UnsignedInt64 and switches printf specifier from %llX to %I64X to fix VC6 compilation error in toHexString().
GeneralsMD/Code/GameEngine/Include/Common/BitFlags.h Identical fix to the Generals counterpart — replaces unsigned long long / %llX with UnsignedInt64 / %I64X for VC6 compatibility in toHexString().

Reviews (4): Last reviewed commit: "fix(vc6): Use UnsignedInt64 and %I64X to..." | Re-trigger Greptile

Comment thread Generals/Code/GameEngine/Include/Common/BitFlags.h Outdated
snprintf(chunkBuf, sizeof(chunkBuf), "%016I64X", val);
else
snprintf(chunkBuf, sizeof(chunkBuf), "%llX", val);
snprintf(chunkBuf, sizeof(chunkBuf), "%I64X", val);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try "%" PRIx64

Copy link
Copy Markdown
Author

@Okladnoj Okladnoj May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since <inttypes.h> does not exist in the MSVC 6.0 standard library, the compiler immediately fails in VC6 mode.

Here are the logs from CI:

Build GeneralsMD / vc6-debug+t+e
##[error]D:\a\GeneralsGameCode\GeneralsGameCode\GeneralsMD\Code\GameEngine\Include\Common/BitFlags.h(34) : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory

@Okladnoj Okladnoj force-pushed the okji/fix-bitflags-vc6 branch 2 times, most recently from 9d90abc to a77a000 Compare May 30, 2026 22:37
@Okladnoj Okladnoj force-pushed the okji/fix-bitflags-vc6 branch from a77a000 to 62a8a4f Compare May 30, 2026 22:39
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