Considerations for restructuring headers and libraries

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

Considerations for restructuring headers and libraries

Earnie Boyd
I'm looking at our coding for MSVCRT, etc and I would like to ask if
anyone thinks that we should continue to code for GCC < 3.3?  For
instance, in the math.h file we have a coding construct as follows
that could easily be cleaned to one line instead of 25 lines if we
simply made the statement that GCC < 3.3 isn't supported.  We could
add to _mingw.h a check and give a #error message if someone thinks
that it is worth the noise.

<code>
#if __MINGW_GNUC_PREREQ(3, 3)
#define HUGE_VAL __builtin_huge_val()
#else

#ifndef __DECLSPEC_SUPPORTED

#ifdef __MSVCRT__
extern double* _imp___HUGE;
#define HUGE_VAL (*_imp___HUGE)
#else
/* CRTDLL */
extern double* _imp___HUGE_dll;
#define HUGE_VAL (*_imp___HUGE_dll)
#endif

#else /* __DECLSPEC_SUPPORTED */

#ifdef __MSVCRT__
__MINGW_IMPORT double _HUGE;
#define HUGE_VAL _HUGE
#else
/* CRTDLL */
__MINGW_IMPORT double _HUGE_dll;
#define HUGE_VAL _HUGE_dll
#endif
</code>

Also, CRTDLL, who is using it?  I asked on mingw-users and no one
responded.  Should we simply remove the possibility of using CRTDLL
with MinGW?  If we do we can clean up quite a bit of seemingly dead
code lines.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-dvlpr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-dvlpr
Reply | Threaded
Open this post in threaded view
|

Re: Considerations for restructuring headers and libraries

Greg Chicares-2
On 2012-08-09 13:24Z, Earnie Boyd wrote:
> I'm looking at our coding for MSVCRT, etc and I would like to ask if
> anyone thinks that we should continue to code for GCC < 3.3?

No.

MinGW gcc-4 uses dw2, which is problematic for C++ GUI programs...so
there is good reason to continue supporting gcc-3.4.5, but I know of
no convincing reason to support any earlier version.

> We could
> add to _mingw.h a check and give a #error message if someone thinks
> that it is worth the noise.

I think it's worth a little noise, e.g.:

#if ! __MINGW_GNUC_PREREQ (3, 4)
#   error Requires at least version 3.4 of gcc.
#endif // ! __MINGW_GNUC_PREREQ (3, 4)

For finer control (e.g., to distinguish 3.4.5 from 3.4.4), we could
use __GNUC_PATCHLEVEL__, which itself requires gcc-3.0 . I hesitate
to offer a direct patch that adds it to __MINGW_GNUC_PREREQ simply
because that's the kind of code I tend to get wrong, so I'll offer
this code that I've written and tested, under any terms you like:

#if defined __GNUC__ && __GNUC__ < 3
#   error Obsolete compiler not supported.
#endif // Ancient gcc compiler.

#if defined __GNUC__
#   define __MINGW_GCC_VERSION \
        (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif // __GNUC__

Example usage (tested):

#if defined __MINGW_GCC_VERSION && __MINGW_GCC_VERSION < 30405
#   error Requires at least version 3.4.5 of gcc.
#endif // defined __MINGW_GCC_VERSION && __MINGW_GCC_VERSION < 30405

> Also, CRTDLL, who is using it?  I asked on mingw-users and no one
> responded.

Not a single objection, and it's been two weeks, so...

>  Should we simply remove the possibility of using CRTDLL
> with MinGW?

Yes. I don't recall ever hearing of any advantage it had over
msvcrt.dll, which seems to be available from microsoft here:
  http://support.microsoft.com/kb/259403
but anyone who uses windows 95 OSR2 or later already has it.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-dvlpr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-dvlpr
Reply | Threaded
Open this post in threaded view
|

Re: Considerations for restructuring headers and libraries

Earnie Boyd
On Thu, Aug 9, 2012 at 4:12 PM, Greg Chicares wrote:

> On 2012-08-09 13:24Z, Earnie Boyd wrote:
>> I'm looking at our coding for MSVCRT, etc and I would like to ask if
>> anyone thinks that we should continue to code for GCC < 3.3?
>
> No.
>
> MinGW gcc-4 uses dw2, which is problematic for C++ GUI programs...so
> there is good reason to continue supporting gcc-3.4.5, but I know of
> no convincing reason to support any earlier version.
>

I've begun to remove filters based on the assumption that we use
gcc-3.4.5 or greater.

>> We could
>> add to _mingw.h a check and give a #error message if someone thinks
>> that it is worth the noise.
>
> I think it's worth a little noise, e.g.:
>
> #if ! __MINGW_GNUC_PREREQ (3, 4)
> #   error Requires at least version 3.4 of gcc.
> #endif // ! __MINGW_GNUC_PREREQ (3, 4)
>
> For finer control (e.g., to distinguish 3.4.5 from 3.4.4), we could
> use __GNUC_PATCHLEVEL__, which itself requires gcc-3.0 . I hesitate
> to offer a direct patch that adds it to __MINGW_GNUC_PREREQ simply
> because that's the kind of code I tend to get wrong, so I'll offer
> this code that I've written and tested, under any terms you like:
>
> #if defined __GNUC__ && __GNUC__ < 3
> #   error Obsolete compiler not supported.
> #endif // Ancient gcc compiler.
>
> #if defined __GNUC__
> #   define __MINGW_GCC_VERSION \
>         (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
> #endif // __GNUC__
>
> Example usage (tested):
>
> #if defined __MINGW_GCC_VERSION && __MINGW_GCC_VERSION < 30405
> #   error Requires at least version 3.4.5 of gcc.
> #endif // defined __MINGW_GCC_VERSION && __MINGW_GCC_VERSION < 30405
>

I'm making an assumption that only gcc is supported as the compiler.
I make noise if __GNUC__ isn't defined as well as different noise for
a version < what is required.

>> Also, CRTDLL, who is using it?  I asked on mingw-users and no one
>> responded.
>
> Not a single objection, and it's been two weeks, so...
>

And anything for CRTDLL will go away.

Another assumption I would like to make and consider is that we
support only Windows versions 4.0 SP1 and greater.  This means that
_WIN32_WINDOWS guards are not needed since this macro is only defined
for earlier versions of Windows.  Any objections to that?  I am doing
this for two reasons, it will be easier to maintain and the fewer
number of lines to read the faster the processes can read it.  I know
the speed up will be negligible but every minute bit helps in the
larger projects.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-dvlpr mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-dvlpr