Hi, how can I disable warnings coming from LLVM .lib files in my VS solution? I’ve tried handling them as external files by using the #include<>
notation, but I’m afraid that doesn’t work for .lib files.
Thanks
Just to clarify, you’re getting warnings when linking against the LLVM .lib files? An example may help here.
Assuming you are, you could always use /IGNORE (https://learn.microsoft.com/en-us/cpp/build/reference/ignore-ignore-specific-warnings?view=msvc-170) to suppress the warning, although that will suppress the warning from all libraries, not just the LLVM ones (I don’t know of a way to be more specific).
Of course, depending on your situation, you could try fixing the warnings properly.
I was under the impression that these warnings were something that LLVM just compiled with, but if you say that I could try fixing them shows me that I was wrong about this. Most of these warnings are, from what I can see, type mismatches - do you know anything about what could be causing these? Note that I’ve compiled with the following command:
cmake -G "Visual Studio 17 2022" -A x64 -B build
cmake --build build --config Release
Most of these warnings are, from what I can see, type mismatches - do you know anything about what could be causing these?
Without knowing the exact warning you’re getting (please post examples of it), I can’t really advise what to do.
(Aside: IIUC, a while back cmake changed the default platform to x64, so there should be no need for -A x64
in your cmake line; this won’t be the cause of the warnings though).
Certainly, here are some of them:
Severity | Code | Description | Project | File | Line | Column | Source | Suppression State |
---|---|---|---|---|---|---|---|---|
Warning | C4244 | ‘argument’: conversion from ‘const StorageType’ to ‘T’, possible loss of data | compiler | C:\dev\thirdparty\llvm\llvm-16.0.0\llvm-install\include\llvm\ADT\Bitfields.h | 180 | 22 | Build | |
Warning | C4244 | ‘argument’: conversion from ‘uint64_t’ to ‘unsigned int’, possible loss of data | compiler | C:\dev\thirdparty\llvm\llvm-16.0.0\llvm-install\include\llvm\IR\Constants.h | 784 | 66 | Build | |
Warning | C4244 | ‘initializing’: conversion from ‘unsigned __int64’ to ‘unsigned int’, possible loss of data | compiler | C:\dev\thirdparty\llvm\llvm-16.0.0\llvm-install\include\llvm\IR\DerivedTypes.h | 472 | 24 | Build |
Thanks for noticing the redundant x64 flag, I’ll remove it .
Those look like compiler warnings, coming from headers, not from the .lib files. As I understand it, there is no guarantee that the #include <>
will suppress warnings any more than #include ""
style (it looks to be implementation defined how the two differ, based on my quick skim of cppreference.com).
When you say they are “coming from LLVM .lib files in my VS solution”, what do you actually mean?
Regardless, I took a quick look at one of the locations in the LLVM headers from where this warning is coming from (specifically the one in Constants.h), and it looks like a simple type mismatch, as indicated by the warning (passing in a 64-bit uint64_t into a function taking a 32-bit unsigned int). Fixing this in the LLVM source code would resolve this warning. It’s not an area I know anything about though, so I can’t advise any further about how to fix it specifically.
You can suppress warnings from third party headers in MSVC, see this Broken Warnings Theory - C++ Team Blog (microsoft.com)