3 ms·
> In C++ there was no way to only run type checking gcc has -fsyntax-only. Despite the option name, this also includes type checking and template instantiation
by ynik 7y ago
> In C++ there was no way to only run type checking
gcc has -fsyntax-only. Despite the option name, this also includes type checking and template instantiation. AFAIK it reports all compiler errors, though it skips some warnings that are computed by the optimizer (e.g. -Wuninitialized).
- fluffything 7y agoIs there an easy way to tell CMake or Makefiles to use it ? I never invoke clang or gcc directly. When using cargo, I use `cargo check` instead of `cargo build`. But in C or C++ depending on the project `make check` might not exist, or it might build all tests and run them, or do something else entirely like checking the formatting using clang-format.
- gpderetta 7y ago> - CMake > - Easy Pick one. I'm sure there is though. It wouldn't be hard with make but then again I'm much more familiar with it than cmake.
- fluffything 7y agoSo I manage to get it to work in the command line using `CXXFLAGS="$CXXFLAGS -fsyntax-check" cmake ... && make` !
- gpderetta 7y agoOne issue with that is that is, unless there is magic handling of the flag in cmake, it might still attempt (and fail) to run the linking stages. You might need custom targets jut for this.
- humanrebar 7y agoDump a compilation database with -CMAKE_EXPORT_COMPILE_COMMANDS=1 and wire up a script to call those commands but with the syntax only flag.