Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSVC] Replace #warning with compatible directives for MSVC #206

Merged

Conversation

FrankXie05
Copy link
Contributor

Summary

This PR addresses an issue where the #warning directive in cpuid_main.c is not supported by MSVC, causing a fatal error (C1021: invalid preprocessor command 'warning'). The warning is used to notify users when libcpuid is built on unsupported CPU architectures, such as ARM.

Changes Made

  • Replaced #warning with a compiler-specific directive.
    • For MSVC (_MSC_VER), used #pragma message to generate a similar warning message.
    • For other compilers, retained #warning for compatibility.
  • The warning is conditionally triggered only for ARM architectures (__arm__ or __aarch64__).

Rationale

This change ensures that libcpuid can be built successfully on MSVC while still providing meaningful warnings for unsupported CPU architectures. It improves cross-platform compatibility without changing the behavior for compilers that support #warning.

Test Plan

  • Verified successful compilation on MSVC with ARM architecture.
  • Ensured the warning message appears in build logs for both MSVC and other compilers.

Example of New Warning

On MSVC:

Related PR: microsoft/vcpkg#42117

@TheTumultuousUnicornOfDarkness
Copy link
Collaborator

I was not able to build with MSVC on ARM due to the lack of ARM-based public Runners on GitHub. Thanks for the fix!

@TheTumultuousUnicornOfDarkness TheTumultuousUnicornOfDarkness merged commit a7d5f29 into anrieff:master Nov 26, 2024
18 of 19 checks passed
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