c4core icon indicating copy to clipboard operation
c4core copied to clipboard

Incorrect detection clang-cl

Open crackedmind opened this issue 1 year ago • 8 comments

https://github.com/biojppm/c4core/blob/master/src/c4/compiler.hpp#L27 It breaks compilation using clang-cl.exe because it defines both _MSC_VER and __clang__ and cannot find alloca.h in rapidyaml. Also it breaks clangd when using msvc toolchain, eg. in qt creator.

crackedmind avatar Jul 16 '24 08:07 crackedmind

Thanks for reporting. I'll need to add a repro to the CI before fixing it. Fixing is easy, the CI less so.

biojppm avatar Jul 16 '24 15:07 biojppm

Thanks for reporting. I'll need to add a repro to the CI before fixing it. Fixing is easy, the CI less so.

Hello just wanted to ask if this will be fixed in the near future?

JordanTheToaster avatar Jun 29 '25 08:06 JordanTheToaster

Thanks for reporting. I'll need to add a repro to the CI before fixing it. Fixing is easy, the CI less so.

Hello just wanted to ask if this will be fixed in the near future?

i used this

Submodule ext/c4core contains modified content
diff --git a/ext/c4core/src/c4/compiler.hpp b/ext/c4core/src/c4/compiler.hpp
index 5833913..d01be74 100644
--- a/ext/c4core/src/c4/compiler.hpp
+++ b/ext/c4core/src/c4/compiler.hpp
@@ -24,7 +24,7 @@
 /** @see http://sourceforge.net/p/predef/wiki/Compilers/ for a list of compiler identifier macros */
 /** @see https://msdn.microsoft.com/en-us/library/b0084kay.aspx for VS2013 predefined macros */
 
-#if defined(_MSC_VER) && !defined(__clang__)
+#if defined(_MSC_VER)
 #   define C4_MSVC
 #   define C4_MSVC_VERSION_2022 17
 #   define C4_MSVC_VERSION_2019 16

crackedmind avatar Jul 02 '25 17:07 crackedmind

i used this

That worked around it for now thank you.

JordanTheToaster avatar Jul 02 '25 18:07 JordanTheToaster

I can't reproduce. Here's what I tried:

+ cmake -S . -B build -G 'Visual Studio 17 2022' -T ClangCL -A x64 -DCMAKE_INSTALL_PREFIX=/d/a/c4core/c4core/install -DCMAKE_BUILD_TYPE=Debug -DC4_CXX_STANDARD=11 -DCXX_STANDARD=11 -DC4CORE_DEV=ON -DC4CORE_BUILD_BENCHMARKS=OFF -DC4CORE_SANITIZE=OFF -DC4CORE_LINT=OFF -DC4CORE_VALGRIND=OFF
-- The CXX compiler identification is Clang 19.1.5 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
# ...

After the config, the compilation also succeeds.

What is the command you are using to trigger this behavior?

biojppm avatar Jul 05 '25 00:07 biojppm

I believe compiling rapidyaml (as it includes the relevant header) triggers the error

TheLastRar avatar Aug 05 '25 16:08 TheLastRar

Please provide the full procedure with all relevant commands.

biojppm avatar Aug 06 '25 13:08 biojppm

Performed in the Developer PowerShell for VS

cd to a directory of choice

git clone https://github.com/biojppm/rapidyaml.git --branch v0.9.0 --recurse-submodules
cd rapidyaml
cmake . -B build -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build build

TheLastRar avatar Aug 06 '25 14:08 TheLastRar