Skip to content

Conversation

@ymartel06
Copy link

Hi,

Quick compilation fix for MSVC.
__builtin_bswap is for clang/GCC and byteswap is for MSVC.

Cheers,
-Yohann

@yellows111
Copy link

Wouldn't this break clang builds on win32?
https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions

@ymartel06
Copy link
Author

@yellows111 Because of _MSC_VER it will only apply for MSVC.
About clang on windows __builtin_bswap16 is supported: https://clang.llvm.org/docs/LanguageExtensions.html#id54

@halotroop2288
Copy link

halotroop2288 commented Mar 8, 2025

Duplicate of a fix I added in #35

In fact both of us may learn from the IDAXEX implementation which should work on Windows, MacOS, and Linux.

@yellows111
Copy link

Because of _MSC_VER it will only apply for MSVC. About clang on windows __builtin_bswap16 is supported: https://clang.llvm.org/docs/LanguageExtensions.html#id54

I do not see _byteswap in that list, which is what I'm concerned about.

I'm concerned due to seeing the following: "This is the default for Windows targets.", and "For compatibility with existing code that compiles with MSVC, clang defines the _MSC_VER and _MSC_FULL_VER macros."

Can someone verify that this change doesn't cause builds using clang-cl to fail?

@halotroop2288
Copy link

@yellows111 I made sure to check for __clang__ first in #35, and it still builds correctly with Clang. I need someone to test the opposite with MSVC.

Clang should not be defining macros made for other compilers though. That's kinda concerning, considering there are very few ways to check the active compiler.

@blueskythlikesclouds
Copy link
Member

Is this needed? I already discourage people from using MSVC, and XenonRecomp's output uses many clang/GCC intrinsics that don't work on MSVC anyway.

@halotroop2288
Copy link

Is this needed? I already discourage people from using MSVC, and XenonRecomp's output uses many clang/GCC intrinsics that don't work on MSVC anyway.

Maybe just don't do that? Seems like a bad idea to me. idk...

@blueskythlikesclouds
Copy link
Member

blueskythlikesclouds commented Apr 12, 2025

MSVC has horrendous code generation/optimization. It shouldn't be used for the output of a project like this.

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.

4 participants