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

Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with clang-tidy.exe #12238

Open
t-mat opened this issue Feb 10, 2025 · 0 comments
Open

Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with clang-tidy.exe #12238

t-mat opened this issue Feb 10, 2025 · 0 comments
Milestone

Comments

@t-mat
Copy link

t-mat commented Feb 10, 2025

Problem

In both of genuine VC++2022 and LLVM environment, clang-tidy.exe reports the following error:

external/SDL3/include/SDL3/SDL_stdinc.h:5972:10: error: 'strings.h' file not found [clang-diagnostic-error]
 5972 | #include <strings.h>
      |          ^~~~~~~~~~~

Reproduction

cmd.exe
cd /d "%PUBLIC%"
md SDL-issue-12238
cd SDL-issue-12238
curl.exe -o main.zip -Ls https://github.com/libsdl-org/SDL/archive/9b18e8438f5225b62dc631a3306d2205be247ce7.zip
tar.exe -xf main.zip
cd SDL-9b18e8438f5225b62dc631a3306d2205be247ce7
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -T ClangCL
cmake --build build -- /nologo /verbosity:minimal /maxcpucount /p:RunCodeAnalysis=true
Reproduce the issue with Visual Studio Community 2022 Preview
  • Setup and build hello.c
  • Navigate to (Menu Bar) > Project > Property > (Left pane) > Configuration Property > General > (Right Pane) > General Property > Platform Toolset
    • Change it to LLVM (clang-cl)
    • Press (Bottom Right) "Apply"
  • Invoke (Menu Bar) > Analyze > Run Code Analysis > Run Code Analysis on [Project Name]
  • C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\Llvm\x64\bin\clang-tidy.exe reports the following error
    Error while processing C:\SDL3-Hello\hello.c.
    C:\SDL3-Hello\external\SDL3-3.2.4\include\SDL3/SDL_stdinc.h(5972,10): error G8FFBB946: 'strings.h' file not found [clang-diagnostic-error]
     5972 | #include <strings.h>
          |          ^~~~~~~~~~~
    Suppressed 1 warnings (1 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
    Found compiler error(s).

Basic analysis

clang-cl.exe + clang-tidy.exe environment predefines the following symbols.

__clang_analyzer__  // clang-tidy.exe
__clang__           // clang-cl.exe
_MSC_VER            // clang-cl.exe

Therefore, the following #if is always true

#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)

But typical Windows environment doesn't have <strings.h>.

#include <strings.h>

Environment information

  • SDL3.2.4 or SDL main branch, commit 9b18e84
  • Windows 11 (24H2)
  • Windows SDK 10.0.26100.0
  • LLVM 19.1.7
  • Visual C++ 2022 : Version 17.13.0 Preview 4.0
  • cmake version 3.31.5
@slouken slouken added this to the 3.2.6 milestone Feb 10, 2025
@t-mat t-mat changed the title Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with LLVM's clang-cl.exe + clang-tidy.exe Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with LLVM's clang-cl.exe + clang-tidy.exe and VC++2022 clang-cl platform toolset Feb 11, 2025
@t-mat t-mat changed the title Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with LLVM's clang-cl.exe + clang-tidy.exe and VC++2022 clang-cl platform toolset Windows, SDL3.2.4: SDL/SDL_stdinc.h has a problem with clang-tidy.exe Feb 11, 2025
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

No branches or pull requests

2 participants