Is "g ++ -MMD" better than enabling scanning?

When looking at build systems, many of them (SCons, bjam, cmake, Tundra, etc.) have a built-in #include scanner. However, gcc and icc offer the -MMD (or -MD ) option, which displays the names of the header files on which the C ++ file depends.

The -MMD dependency -MMD seems reliable. If you add #include to the C file, its timestamp will change so that the build system recompiles it. If you add #include to the header file, its timestamp will change and will recompile all affected C files.

Turn on the scanning systems, but -MMD will seem reliable. Which is better and why?

+4
source share
1 answer

-MMD better for the reasons you give and more.

Getting the compiler to output the dependencies as part of the normal compilation process ensures that the exact same set of compiler options, like -I paths and macros, is valid for compiling and when looking for dependencies. This less redundant and less error prone than providing the same parameters is used for two separate tools.

+4
source

All Articles