How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Thomas Steinbach
Hello,

I'm trying to set up mingw 4.x but
how can I differentiate between mingw version >= 4.x.x
and mingw gcc 3.x.x while compiling?

Currently I use:

__MINGW_H

to detect mingw in general. But now I have to differentiate
the 3.x and 4.x versions.

Thomas


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Tuomo Latto
Thomas Steinbach wrote:

> I'm trying to set up mingw 4.x but
> how can I differentiate between mingw version >= 4.x.x
> and mingw gcc 3.x.x while compiling?
>
> Currently I use:
>
> __MINGW_H
>
> to detect mingw in general. But now I have to differentiate
> the 3.x and 4.x versions.

http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros


--
Tuomo

... When all else fails, read the instructions


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Thomas Steinbach
Hello Tuomo,

>> Currently I use:
>>
>> __MINGW_H
>>
>> to detect mingw in general. But now I have to differentiate
>> the 3.x and 4.x versions.
>
> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros

thank you and looks not bad, but these are constants are used to
differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
mingw (with gcc 3.c). and mingw with gcc 4.x

But I found

__MINGW64

and think this is the right constant to differentiate between these
two "environments".

But I'm not sure if this constant is defined _every_ time, when
compiling with gcc 4.x, indenpendent if it is for 32 bit or 64 bit.

Does anybody know that?

Thomas



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

JonY-2
On 8/9/2009 05:45, Thomas Steinbach wrote:

> Hello Tuomo,
>
>>> Currently I use:
>>>
>>> __MINGW_H
>>>
>>> to detect mingw in general. But now I have to differentiate
>>> the 3.x and 4.x versions.
>>
>> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros
>
> thank you and looks not bad, but these are constants are used to
> differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
> mingw (with gcc 3.c). and mingw with gcc 4.x
>

Hi,
aren't both situations the same? Can you please clarify?

> But I found
>
> __MINGW64
>
> and think this is the right constant to differentiate between these
> two "environments".
>
> But I'm not sure if this constant is defined _every_ time, when
> compiling with gcc 4.x, indenpendent if it is for 32 bit or 64 bit.
>
> Does anybody know that?
>

__MINGW64 is not a built-in GCC define, use "gcc -xc -E /dev/null -dD"
to see the built-ins.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Charles Wilson-2
In reply to this post by Thomas Steinbach
Thomas Steinbach wrote:

> Hello Tuomo,
>
>>> Currently I use:
>>>
>>> __MINGW_H
>>>
>>> to detect mingw in general. But now I have to differentiate
>>> the 3.x and 4.x versions.
>> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros
>
> thank you and looks not bad, but these are constants are used to
> differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
> mingw (with gcc 3.c). and mingw with gcc 4.x
>
> But I found
>
> __MINGW64
>
> and think this is the right constant to differentiate between these
> two "environments".

No. It is not.

What you want is:

#if defined(__MINGW32__) || defined(__MINGW64__)
  /* __GNUC__ will always be defined, because there is
     no such thing as "mingw" without "gcc" */
# define MYPACKAGE_MINGW_GCC __GNUC__
#endif

then, in your code you can do:

#if defined(MYPACKAGE_MINGW_GCC)
# if MYPACKAGE_MINGW_GCC == 3
   /* mingw gcc 3 code */
# elif MYPACKAGE_MINGW_GCC == 4
   /* mingw gcc 4 code */
# else
   error "mingw with gcc 2.x or 5.x not supported"
# endif
#else
   /* other platforms */
#endif

--
Chuck

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Gregory McGarry
> What you want is:

>
> #if defined(__MINGW32__) || defined(__MINGW64__)
>   /* __GNUC__ will always be defined, because there is
>      no such thing as "mingw" without "gcc" */
> # define MYPACKAGE_MINGW_GCC __GNUC__
> #endif

pcc uses the mingw runtime, and it doesn't define __GNUC__.

So I think the question is valid.  How does one test for features in the mingw runtime?


      __________________________________________________________________________________
Find local businesses and services in your area with Yahoo!7 Local.
Get started: http://local.yahoo.com.au

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Greg Chicares
On 2009-08-10 08:32Z, Gregory McGarry wrote:

>> What you want is:
>
>>
>> #if defined(__MINGW32__) || defined(__MINGW64__)
>>   /* __GNUC__ will always be defined, because there is
>>      no such thing as "mingw" without "gcc" */
>> # define MYPACKAGE_MINGW_GCC __GNUC__
>> #endif
>
> pcc uses the mingw runtime, and it doesn't define __GNUC__.
>
> So I think the question is valid.  How does one test for features in the mingw runtime?

In that case I'd suggest:
  #if defined __MINGW32_VERSION
That's defined in 'include/_mingw.h', which every MinGW header
includes--so test it after including at least one MinGW header.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Charles Wilson-2
In reply to this post by Gregory McGarry
Gregory McGarry wrote:
>> What you want is:
>
>> #if defined(__MINGW32__) || defined(__MINGW64__)
>>   /* __GNUC__ will always be defined, because there is
>>      no such thing as "mingw" without "gcc" */
>> # define MYPACKAGE_MINGW_GCC __GNUC__
>> #endif
>
> pcc uses the mingw runtime, and it doesn't define __GNUC__.

Then, as far as THIS list is concerned, it is not MinGW.  It's "some
sort of native win32 environment, compiled by some specific BSD-licensed
compiler, that happens to piggyback on the mingw runtime".  If pcc takes
the shortcut -- to allow direct use of the mingw runtime and headers --
of automatically #defining __MINGW32__ so as to trigger the snippet
above without __GNUC__, well...I think that's indicative of a misfeature
in pcc.  It is *not* MinGW, so it shouldn't be defining __MINGW32__.
But maybe that's just me.

Whether the OP wants to support pcc, is up to him -- but it wasn't the
question he asked.  And, it especially makes no difference to the OP,
since he was trying to distinguish between gcc-3.x and gcc-4.x.  pcc
wasn't in the mix.  True, my code snippet would require additional
changes to also support pcc. It would require changes to support Intel's
compiler, and Borland's compiler, and Watcom, etc.  None of those are
"MinGW" either.

> So I think the question is valid.  How does one test for features in the mingw runtime?

That's a different question (and Greg C. has already answered it)

--
Chuck


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

NightStrike
In reply to this post by Charles Wilson-2
On Sat, Aug 8, 2009 at 8:04 PM, Charles
Wilson<[hidden email]> wrote:

> Thomas Steinbach wrote:
>> Hello Tuomo,
>>
>>>> Currently I use:
>>>>
>>>> __MINGW_H
>>>>
>>>> to detect mingw in general. But now I have to differentiate
>>>> the 3.x and 4.x versions.
>>> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros
>>
>> thank you and looks not bad, but these are constants are used to
>> differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
>> mingw (with gcc 3.c). and mingw with gcc 4.x
>>
>> But I found
>>
>> __MINGW64
>>
>> and think this is the right constant to differentiate between these
>> two "environments".
>
> No. It is not.
>
> What you want is:
>
> #if defined(__MINGW32__) || defined(__MINGW64__)
>  /* __GNUC__ will always be defined, because there is
>     no such thing as "mingw" without "gcc" */
> # define MYPACKAGE_MINGW_GCC __GNUC__
> #endif
>
> then, in your code you can do:
>
> #if defined(MYPACKAGE_MINGW_GCC)
> # if MYPACKAGE_MINGW_GCC == 3
>   /* mingw gcc 3 code */
> # elif MYPACKAGE_MINGW_GCC == 4
>   /* mingw gcc 4 code */
> # else
>   error "mingw with gcc 2.x or 5.x not supported"
> # endif
> #else
>   /* other platforms */
> #endif

I'm probably misunderstanding here, but how does the existence of the
__MINGW64__ macro imply that the GCC version is 4?  The GNUC macros
typically contain the GCC version, with major and minor variants.  For
instance, on gcc 4.4.1:

#define __GNUC__ 4
#define __GNUC_MINOR__ 4
#define __GNUC_PATCHLEVEL__ 1

Isn't this what the OP really wants?  The __MINGW64__ macro says
nothing about the version of the compiler used (aside from the fact
that right now, we don't support anything less than 4.3.. but that's
by chance, not by definition).

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

Charles Wilson-2
NightStrike wrote:

> On Sat, Aug 8, 2009 at 8:04 PM, Charles
> Wilson<[hidden email]> wrote:
>> Thomas Steinbach wrote:
>>> Hello Tuomo,
>>>
>>>>> Currently I use:
>>>>>
>>>>> __MINGW_H
>>>>>
>>>>> to detect mingw in general. But now I have to differentiate
>>>>> the 3.x and 4.x versions.
>>>> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros
>>> thank you and looks not bad, but these are constants are used to
>>> differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
>>> mingw (with gcc 3.c). and mingw with gcc 4.x
>>>
>>> But I found
>>>
>>> __MINGW64
>>>
>>> and think this is the right constant to differentiate between these
>>> two "environments".
>> No. It is not.
>>
>> What you want is:
>>
>> #if defined(__MINGW32__) || defined(__MINGW64__)
>>  /* __GNUC__ will always be defined, because there is
>>     no such thing as "mingw" without "gcc" */
>> # define MYPACKAGE_MINGW_GCC __GNUC__
>> #endif
>>
>> then, in your code you can do:
>>
>> #if defined(MYPACKAGE_MINGW_GCC)
>> # if MYPACKAGE_MINGW_GCC == 3
>>   /* mingw gcc 3 code */
>> # elif MYPACKAGE_MINGW_GCC == 4
>>   /* mingw gcc 4 code */
>> # else
>>   error "mingw with gcc 2.x or 5.x not supported"
>> # endif
>> #else
>>   /* other platforms */
>> #endif
>
> I'm probably misunderstanding here, but how does the existence of the
> __MINGW64__ macro imply that the GCC version is 4?  

It doesn't, and the code above doesn't assume so.  In pseudo code:

if mingw (that is, if __MINGW32__ or __MINGW64__)
  then my_mingw_gcc_ver = __GNUC__

if my_mingw_gcc_ver is defined
  then if my_mingw_gcc_ver == 3
     do stuff, for gcc3 + (mingw32 or mingw64, either one)
  else if my_mingw_gcc_ver == 4
     do stuff, for gcc4 + (mingw32 or mingw64, either one)
  else
     error

--
Chuck





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: How to differentiate mingw ersion >= 4.x.x and ver. 3.x.x

NightStrike
On Wed, Aug 12, 2009 at 1:18 PM, Charles
Wilson<[hidden email]> wrote:

> NightStrike wrote:
>> On Sat, Aug 8, 2009 at 8:04 PM, Charles
>> Wilson<[hidden email]> wrote:
>>> Thomas Steinbach wrote:
>>>> Hello Tuomo,
>>>>
>>>>>> Currently I use:
>>>>>>
>>>>>> __MINGW_H
>>>>>>
>>>>>> to detect mingw in general. But now I have to differentiate
>>>>>> the 3.x and 4.x versions.
>>>>> http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html#Common-Predefined-Macros
>>>> thank you and looks not bad, but these are constants are used to
>>>> differentiate between gcc 3 and gcc 4 (or other versions), not to sepereate
>>>> mingw (with gcc 3.c). and mingw with gcc 4.x
>>>>
>>>> But I found
>>>>
>>>> __MINGW64
>>>>
>>>> and think this is the right constant to differentiate between these
>>>> two "environments".
>>> No. It is not.
>>>
>>> What you want is:
>>>
>>> #if defined(__MINGW32__) || defined(__MINGW64__)
>>>  /* __GNUC__ will always be defined, because there is
>>>     no such thing as "mingw" without "gcc" */
>>> # define MYPACKAGE_MINGW_GCC __GNUC__
>>> #endif
>>>
>>> then, in your code you can do:
>>>
>>> #if defined(MYPACKAGE_MINGW_GCC)
>>> # if MYPACKAGE_MINGW_GCC == 3
>>>   /* mingw gcc 3 code */
>>> # elif MYPACKAGE_MINGW_GCC == 4
>>>   /* mingw gcc 4 code */
>>> # else
>>>   error "mingw with gcc 2.x or 5.x not supported"
>>> # endif
>>> #else
>>>   /* other platforms */
>>> #endif
>>
>> I'm probably misunderstanding here, but how does the existence of the
>> __MINGW64__ macro imply that the GCC version is 4?
>
> It doesn't, and the code above doesn't assume so.  In pseudo code:
>
> if mingw (that is, if __MINGW32__ or __MINGW64__)
>  then my_mingw_gcc_ver = __GNUC__
>
> if my_mingw_gcc_ver is defined
>  then if my_mingw_gcc_ver == 3
>     do stuff, for gcc3 + (mingw32 or mingw64, either one)
>  else if my_mingw_gcc_ver == 4
>     do stuff, for gcc4 + (mingw32 or mingw64, either one)
>  else
>     error


Ah, I get it now.  Thanks for clearing that up!  This is what I missed:
>  then my_mingw_gcc_ver = __GNUC__

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users