Re: [Mingw-users] windows.h dependency
On Saturday 02 February 2008 17:15, Greg Chicares wrote:
> On 2008-02-02 16:49Z, NightStrike wrote:
> > [...] I tried individually
> > compiling every header in mingw with something like this in a
> > script where $file is each .h header:
> >
> > #include <$file>
> > int main() {return 0;}
>
> This tests for the desirable property Lakos calls 'closure'.
> I test it automatically before committing any header to my
> own repository. BTW, you can test it this simpler way:
> http://article.gmane.org/gmane.comp.gnu.mingw.user/20528
>
> | g++ -xc++ -fsyntax-only eraseme.hpp
>
> without creating any dummy main module.
It's also a feature that is checked by autoconf's AC_CHECK_HEADER macro,
(which does create, and subsequently deletes, a temporary source file).
> > The number of errors drops considerably when I change it to:
> >
> > #include <windows.h>
> > #include <$file>
> > int main() {return 0;}
> >
> >
> > So basically, a number of mingw headers won't compile unless
> > windows.h is also included. If those headers require windows.h, I
> > would think that they should include it themselves.
>
> I agree.
So do I. However, do note that this scenario isn't exclusive to
windows.h; some implementations of the standard C library provide
headers with an internal dependency on, say, `sys/types.h', yet they
don't automatically #include it; (the accompanying manpages would
simply state the requirement to '#include <sys/types.h>' before the
applicable dependent header).
> > I am assuming that I am misunderstanding something here that
> > everyone sees very clearly. Could you enlighten me?
>
> See the last paragraph of:
> http://article.gmane.org/gmane.comp.gnu.mingw.user/25389
> I think it's an ancient msw pitfall that we needn't
> perpetuate, so I'd be happy if you want to fix it.
Of course, patches will be welcome. In the meantime, if you are looking
for an autoconf strategy to check for header foo.h, which may depend on
windows.h, you could use:--
AC_CHECK_HEADERS([windows.h])
AC_CHECK_HEADERS([foo.h],[],[],
[#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
])
Do note the use of AC_CHECK_HEADERS, rather than AC_CHECK_HEADER; this
is simply for greater convenience in updating config.h -- see the
autoconf documentation, for the explanation.
Regards,
Keith.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users