Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does MinGW automatically include <windef.h>

Tags:

c++

windows

mingw

I am trying to typedef DWORD in a platform agnostic manner, and I am running into the following compiler error:

...\mingw.org\mingw_gcc_4.5.0\bin\../lib/gcc/mingw32/4.5.0/../../
../../include/windef.h:229:23: error: 
'DWORD' has a previous declaration as 'typedef long unsigned int DWORD'

I'd like to be able to depend on my implementation of DWORD and not on the underlying compiler knowing what it is (using typedefs, not macros).

Why does mingw (gcc 4.5.0) automatically include "windef.h" when an application is compiled?

How does one prevent this inclusion?

like image 871
J T Avatar asked Aug 25 '26 01:08

J T


1 Answers

My MinGW doesn't seem to automatically pull in windef.h. I suspect that your program is including some other header that's indirectly pulling it in. Can you post a short program that displays the problem?

Note that I see you're using whether or not _WINDEF_H is defined to determine if these things have already been typedef'ed. That might work when MinGW is being used, but the actual Windows SDK defines _WINDEF_ when windef.h is included - at least one specific version. I imagine this is fairly stable, but it's certainly possible that this has changed at some point.

It might be better to key on something like the macro MAKEWORD to detect whether windef.h has already been included - MAKEWORD is documented as being a macro defined in windef.h, so it should be stable across SDK versions, whether from Microsoft or not.

like image 68
Michael Burr Avatar answered Aug 27 '26 16:08

Michael Burr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!