clang diagnostic error: definition of builtin function
See original GitHub issueWhen using CPT on a file that eventually includes winnt.h
(e.g. by including MFC-Header afxmt.h
), I get the following errors
Error while processing C:\foo.cpp.
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5419): error: definition of builtin function '_InterlockedAnd64' [clang-diagnostic-error]
_InterlockedAnd64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5492): error: definition of builtin function '_InterlockedOr64' [clang-diagnostic-error]
_InterlockedOr64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5512): error: definition of builtin function '_InterlockedXor64' [clang-diagnostic-error]
_InterlockedXor64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5532): error: definition of builtin function '_InterlockedIncrement64' [clang-diagnostic-error]
_InterlockedIncrement64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5553): error: definition of builtin function '_InterlockedDecrement64' [clang-diagnostic-error]
_InterlockedDecrement64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5572): error: definition of builtin function '_InterlockedExchange64' [clang-diagnostic-error]
_InterlockedExchange64 (
^
C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(5595): error: definition of builtin function '_InterlockedExchangeAdd64' [clang-diagnostic-error]
_InterlockedExchangeAdd64 (
^
I am not sure if these have anything to do with CPT or my individual setup.
I am using
- Visual Studio 2022 (17.5.0)
- CPT 2023.2.1
- LLVM 15.0.7
- Windows SDK 8.1
Any ideas what is going wrong here or how to trace down this issue further?
Issue Analytics
- State:
- Created 7 months ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Diagnostic flags in Clang — Clang 18.0.0git documentation
This diagnostic is an error by default, ... warning: declaration of built-in function 'B' requires inclusion of the header <A> ...
Read more >Cannot suppress error for gcc intrin. · Issue #1203 · clangd/ ...
My project is built using conan+cmake and gcc10 from devtoolset-10. Clangd is complaining about some gcc-specific headers and I found no way ...
Read more >[llvm-dev] Over-ride the compiler built-in functions .
Umesh Kalappa via llvm-dev's profile photo ... clang throws the error like ... test.c:1:6: error: definition of builtin function ...
Read more >avoid clang-diagnostic-error interrupting build ...
It seems that cmake captures standard error from the command and throws it way, hence the error message.
Read more >include/clang/Basic/DiagnosticSemaKinds.td
"variable length array must be bound in function definition">; ... def err_builtin_definition : Error<"definition of builtin function %0">;.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @mariru27,
thank you for looking into this and implementing a fix.
Unfortunately it seems that it wasn’t the root cause for the ‘definition of builtin function’ problem. I checked it with the v140 toolset and also with the v143 toolset (since we upgraded in the meantime).
Running the command invoked by CPT manually produces the same result.
I did some tests and it seems the problem only occurs when compiling for 32 bit using the Win SDK 8.1 (we are already working on upgrading the SDK version).
Hi @MarcelNehring,
You can update Clang Power Tools to v2023.5.0
Thank you for your help, means a lot for our product
Have a nice day, Marina