Running clangd-tidy src/main.cpp:1:1: Error: Unknown argument: '-fmodules-ts'…
- User
Running clangd-tidy src/main.cpp:1:1: Error: Unknown argument: '-fmodules-ts' [drv_unknown_argument] 1 | #include <sys/types.h> | ^ 2 | 3 | #include <coro/coro.hpp> src/main.cpp:1:1: Error: Unknown argument: '-fmodule-mapper=CMakeFiles/digital-twin.dir/src/main.cpp.o.modmap' [drv_unknown_argument] 1 | #include <sys/types.h> | ^ 2 | 3 | #include <coro/coro.hpp> src/main.cpp:1:1: Error: Unknown argument: '-fdeps-format=p1689r5' [drv_unknown_argument] 1 | #include <sys/types.h>
- Assistant
This error occurs because clang-tidy doesn't recognize the C++20 modules-related compiler flags that CMake is passing to it. These flags (
-fmodules-ts,-fmodule-mapper,-fdeps-format=p1689r5) are specific to the compilation process but aren't needed for static analysis.Here are a few ways to fix this:
Option 1: Filter out modules flags in compile_commands.json
If you're using CMake, you can create a script to clean up the compile commands:
# Remove problematic flags from compile_commands.json sed -i 's/-fmodules-ts//g; s/-fmodule-mapper=[^ ]*//g; s/-fdeps-format=[^ ]*//g' compile_commands.jsonOption 2: Configure clang-tidy to ignore these flags
Create a
.clang-tidyfile in your project root:--- Checks: '*' CheckOptions: - key: misc-unused-parameters.StrictMode value: true CompileFlags: Remove: [-fmodules-ts, -fmodule-mapper=*, -fdeps-format=*]Option 3: Use a wrapper script
Create a wrapper that filters the arguments:
#!/bin/bash # clang-tidy-wrapper.sh args=() for arg in "$@"; do case "$arg" in -fmodules-ts|-fmodule-mapper=*|-fdeps-format=*) # Skip these arguments ;; *) args+=("$arg") ;; esac done exec clang-tidy "${args[@]}"Option 4: CMake configuration
If you're generating the compile commands with CMake, you can modify your CMakeLists.txt to conditionally add these flags only for actual compilation:
if(NOT CMAKE_EXPORT_COMPILE_COMMANDS) target_compile_options(your_target PRIVATE -fmodules-ts) # other module flags... endif()The easiest immediate fix is probably Option 1 - just clean up the compile_commands.json file after CMake generates it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.