Discussion:
[Mingw-w64-public] Detect mingw
Алексей Павлов
2012-10-16 04:30:01 UTC
Permalink
How can I detect in program that toolchain use mingw-w64 not original mingw?
Antony Riakiotakis
2012-10-16 06:13:41 UTC
Permalink
Usually __MINGW64__ is defined so you can check for that in the source.
Kai Tietz
2012-10-16 06:45:55 UTC
Permalink
Post by Antony Riakiotakis
Usually __MINGW64__ is defined so you can check for that in the source.
First, that define is only set for 64-bit mode, but mingw-w64 also
supports 32-bit (old mingw.org) mode. Secondly that define is
provided by the compiler and isn't runtime-specific at all.
As long as programmer of an application didn't provided a function to
answer your question, you won't be able to detect it that easy. There
are ways to find out by inspecting startup-code, which is slightly
different between both ventures.

Regards,
Kai
Ruben Van Boxem
2012-10-16 09:24:13 UTC
Permalink
Post by Kai Tietz
Post by Antony Riakiotakis
Usually __MINGW64__ is defined so you can check for that in the source.
First, that define is only set for 64-bit mode, but mingw-w64 also
supports 32-bit (old mingw.org) mode. Secondly that define is
provided by the compiler and isn't runtime-specific at all.
As long as programmer of an application didn't provided a function to
answer your question, you won't be able to detect it that easy. There
are ways to find out by inspecting startup-code, which is slightly
different between both ventures.
Something I use when I need it:

#ifdef __MINGW32__ // on some form of MinGW toolchain
#include <_mingw.h> // MinGW internal header present for all MinGW variants
#ifdef __MINGW64_VERSION_MAJOR
// We're compiling with MinGW-w64 32 or 64-bit
#else
// We're compiling with MinGW.org
#endif
#endif

See here:
http://www.mail-archive.com/mingw-w64-***@lists.sourceforge.net/msg00638.html
__MINGW64__ only really signifies x64 Windows and MinGW. I bet that if
MinGW.org ever come with a 64-bit variant (not likely), they'd define this
for consistency (just as MinGW-w64 does).

If you need to detect bitness as well, use the builtin GCC defines for
architecture: http://sourceforge.net/p/predef/wiki/Architectures/

Ruben
Post by Kai Tietz
Regards,
Kai
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Алексей Павлов
2012-10-16 10:35:51 UTC
Permalink
Thanks for answers! I need this because support for wmihelper in Qt5 for
mingw-w64
Post by Ruben Van Boxem
Post by Kai Tietz
Post by Antony Riakiotakis
Usually __MINGW64__ is defined so you can check for that in the source.
First, that define is only set for 64-bit mode, but mingw-w64 also
supports 32-bit (old mingw.org) mode. Secondly that define is
provided by the compiler and isn't runtime-specific at all.
As long as programmer of an application didn't provided a function to
answer your question, you won't be able to detect it that easy. There
are ways to find out by inspecting startup-code, which is slightly
different between both ventures.
#ifdef __MINGW32__ // on some form of MinGW toolchain
#include <_mingw.h> // MinGW internal header present for all MinGW variants
#ifdef __MINGW64_VERSION_MAJOR
// We're compiling with MinGW-w64 32 or 64-bit
#else
// We're compiling with MinGW.org
#endif
#endif
__MINGW64__ only really signifies x64 Windows and MinGW. I bet that if
MinGW.org ever come with a 64-bit variant (not likely), they'd define this
for consistency (just as MinGW-w64 does).
If you need to detect bitness as well, use the builtin GCC defines for
architecture: http://sourceforge.net/p/predef/wiki/Architectures/
Ruben
Post by Kai Tietz
Regards,
Kai
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mingw-w64-public mailing list
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Earnie Boyd
2012-10-16 12:01:25 UTC
Permalink
Post by Ruben Van Boxem
__MINGW64__ only really signifies x64 Windows and MinGW. I bet that if
MinGW.org ever come with a 64-bit variant (not likely), they'd define this
for consistency (just as MinGW-w64 does).
Since it is defined by the compiler, of course a MinGW.org provided
64-bit compiler would define it. The "(not likely)" is not likely
true. ;p
--
Earnie
-- https://sites.google.com/site/earnieboyd
Loading...