gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Size difference between BOOL, WinBOOL, and BOOL results in incorrect arc


From: Hugo Melder
Subject: Size difference between BOOL, WinBOOL, and BOOL results in incorrect archiving under Windows MSVC
Date: Mon, 1 Aug 2022 12:10:32 +0200

Hi Y’all,

I'm currently investigating various libs-base test failures on Windows 11 MSVC and I’m stuck on one particular failure involving the archiving and unarchiving of primitives into a binary bundle (Tests/base/coding/basictypes.m).

Apple describes NSArchiver as “[..] a concrete subclass of NSCoder [and] provides a way to encode objects into an architecture-independent format that can be stored in a file”. That’s why the test has precomputed .type files (e.g. BOOL-1.type) to validate the output of the archiver.

This validation fails: On Windows 11 MSVC a bool is 4-bytes long, thus the generated .type file is BOOL-4.type and the unarchive routine fails:

Failed test:     (2022-06-17 06:35:35.907 +0000) basictypes.m:157 ... can unarchive BOOL from D:/a/libs-base/libs base/source/Tests/base/coding/BOOL-1.type


Now, there has been some issues related to the difference between BOOL, WinBOOL, and WINBOOL (https://github.com/gnustep/libs-base/pull/247#discussion_r835060626).

Here the difference:
  • I can’t find the definition of WinBOOL anywhere in the Windows Kit header files, nor online.
  • WINBOOL seems to be implicitly defined by the compiler switch -Ze and explicitly defined in GNUstep.
  • BOOL is defined as typedef int in Windows.h.

Maybe we can explicitly pack BOOL into one byte while archiving to maintain the architecture-independent format, or redefine BOOL in GNUstep to the correct size?

Best Regards

Hugo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]