title: What is the smallest Windows header I can #include to define DWORD?
body: <p>I have a small header file of my own which declares a couple of functions, one of which has a return type of <code>DWORD</code>.  I'm reluctant to drag in <code>windows.h</code> just to get the official definition of this type since that file is huge, and my header will be used in a number of source modules that don't otherwise need it.</p>
  
  <p>Of course, in practice I know that <code>DWORD</code> is just <code>unsigned int</code>, but I'd prefer the more hygienic approach of including an official header file if possible.</p>
  
  <p>On <a href="http://msdn.microsoft.com/en-us/library/aa383751%28VS.85%29.aspx" rel="noreferrer">this page</a> it says that <code>DWORD</code> is defined in <code>windef.h</code>, but unfortunately including just this small file directly leads to compilation errors -- apparently it expects to be included by other headers.  (Also, the fact that my file is a header file also means I can't just declare <code>WIN32_LEAN_AND_MEAN</code>, since the source file that #includes my file might need this to be left undefined.)</p>
  
  <p>Any ideas?  I know it's not the end of the world -- I can just continue to <code>#include &lt;windows.h&gt;</code> -- but thought someone might have a better idea!</p>
  
  <p><strong>[EDIT]</strong>
  Thanks for your responses.  To those who suggested using a different type, let me explain why that's not desirable in this case: I've set up different, platform-specific versions of the two functions in different source files, and ask the CMake configuration to detect the current platform and choose which one to build.  On Windows, my functions look like:</p>
  
  <pre><code>typedef DWORD TimePoint;
  TimePoint GetTimeNow(void);
  double TimeDifference(TimePoint start, TimePoint end);
  </code></pre>
  
  <p>The Windows version of <code>GetTimeNow()</code> just calls the Windows API <code>timeGetTime()</code>, which has return type <code>DWORD</code>, and so it must have the same return type.  (On other platforms, <code>TimePoint</code> will have a different type, e.g. <code>struct timeval</code> on UNIXy platforms.)  In effect, values of type <code>TimePoint</code> are opaque, and the only thing you can do with them is pass two of them to <code>TimeDifference()</code> to measure the elapsed time between them in seconds.  This enables cross-platform development.  Unfortunately it still means that client code has to know the concrete type of <code>TimePoint</code>.</p>