On 01/28/2015, Lasse Collin wrote:
On 2015-01-23 Gabi Davar wrote:
I've created vs2013 based solution for lzma DLL, lzma static and most
utils. It based on the works of Garen & Mārtiņš Možeiko.
It can be found at https://github.com/mindw/xz vs2013_520 branch.
  [[snip]]
   - Including <windows.h> in mytime.c shouldn't be needed because
     private.h already does that.


Please do not rely on transitive #include.  Retain the "#include <windows.h>"
in mytime.c as long as anything in mytime.c relies on anything in <windows.h>,
namely GetTickCount64().

The rule should be, "If code in a file uses a symbol (name of function,
variable, macro, typedef, struct, etc.) then the file must provide
the appropriate declaration within the file itself, or via
a specific #include which contains such a declaration directly."

Abiding by that rule makes it easier to read, understand, and maintain
the code because each search for declaration will succeed with a #include
depth of at most 1.  The rule makes the code more robust, because
changes to the intermediate #includes (such as removing the
transitive #include) cannot result in surprises.  Surprises are
particularly likely with older compilers, where the omission of
a function prototype might not be detected by default.
Instead, the compiler silently uses the default prototype
        int func(...);
which cannot detect type errors in arguments, and likely will cause
bad code if any of the actual types is not 'int' or pointer.

--


Reply via email to