Skip to content

Conversation

@zhiningli
Copy link
Contributor

@zhiningli zhiningli commented Dec 13, 2025

Summary

Enables the error message type printing feature (ZL_ENABLE_RET_IF_ARG_PRINTING) on clang-cl and fixes a cross-platform test incompatibility.

Issue 1: Type printing disabled on clang-cl

File: include/openzl/detail/zl_errors_detail.h (line 570)

The preprocessor check for enabling verbose error messages only checked for _GNUC_. However, clang-cl defines _clang_ instead, causing the feature to remain disabled on Windows/Clang builds.

Before:

if defined(\__GNUC_\_) && !defined(\__cplusplus)

After:

if (defined(\__GNUC_\_) || defined(\__clang_\_)) && !defined(\__cplusplus)

Issue 2: Enum type differs between platforms

File: tests/unittest/common/test_errors_in_c.c (line 223)

C enums have different underlying types depending on the platform ABI:

  • Linux/GCC: unsigned int
  • Windows/MSVC ABI: int
  • ARM64: May use either depending on ABI
    The test previously expected a strict string match that failed on Windows.

Before:

EXPECT_ERROR_MESSAGE_CONTAINS(e_1, e_2, "(unsigned int)");

After:

// Explicitly check for both possibilities using exact string matching
const char* _found_int  = strstr(_str, "(int)");
const char* _found_uint = strstr(_str, "(unsigned int)");
if (!_found_int && !_found_uint) {
    ZL_RET_R_ERR(GENERIC, "Message '(int)' or '(unsigned int)' not found...");
}  

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Plan

Test affected: ErrorsTest.BinaryTestArgTypesDeducedInC (Test #306)

Built and ran the full test suite on Windows.

cmake --build build --config Release  
cd build && ctest -C Release --timeout 60  

Result:

1209/1209 tests passing (100%)

image

After windows compatibility fix #97, #299, #301

Specifically verified the affected test:

ctest -C Release -R "ErrorsTest.BinaryTestArgTypesDeducedInC" --output-on-failure

Output:

# Result: 1/1 Test #306: ErrorsTest.BinaryTestArgTypesDeducedInC ... Passed

Test Configuration

| Component | Detail |
| Compiler | clang-cl (ClangCL toolset) |
| Generator | Visual Studio with ClangCL toolset (-T ClangCL) |
| Build type | Release |
| Platform | Windows 11 x64 |

@meta-cla meta-cla bot added the cla signed label Dec 13, 2025
@zhiningli zhiningli requested a review from terrelln December 15, 2025 16:36
@meta-codesync
Copy link

meta-codesync bot commented Dec 19, 2025

@zhiningli has imported this pull request. If you are a Meta employee, you can view this in D89547438.

…tform enum test

- Enable ZL_ENABLE_RET_IF_ARG_PRINTING for clang-cl by adding __clang__ check
- Fix enum type test to work on both Linux (unsigned int) and Windows (int)

The error message type printing feature was disabled on clang-cl because
the preprocessor check only looked for __GNUC__. Since clang-cl defines
__clang__, adding this check enables the feature.

The enum type test expected '(unsigned int)' but Windows/MSVC ABI uses
'(int)' for C enums. Changed to match '(int' which works on both platforms.
The substring '(int' was too permissive and could match unintended types
like '(int32_t)'. Changed to explicitly check for both '(int)' and
'(unsigned int)' using exact string matching, which works across all
platforms (Linux, Windows, ARM64).
@meta-codesync
Copy link

meta-codesync bot commented Dec 20, 2025

@zhiningli merged this pull request in 3924936.

@zhiningli zhiningli self-assigned this Dec 20, 2025
@zhiningli zhiningli deleted the windows-error-type-printing branch December 23, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants