Web lists-archives.com

Re: [Mingw-users] Does MinGW not support -std=c++11 flag?




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/10/16 23:55, Keith Marshall wrote:
> On 09/10/16 17:27, DAVENPORT, MARC wrote:
>> Clayton Weaver <mingwuser@xxxxxxxxx> wrote:
>>> I got the same errors with Allegro 5. Upon trying to compile an
>>>  old A5 project with -std=c++11 I got the same errors mentioned
>>>  about off_t and even got errors pertaining to cwchar.h stating
>>>  ::wcscat, wcscmp, and several others were not declared. For 
>>> Allegro 5, for now, it appears you have to pass -std=gnu++11 to
>>>  compile or use a C++ library like SFML to make games or apps.
> 
>> I can confirm this. My library build using A5 and C++11 does the
>>  same thing. There's also an error regarding _fsize_t being 
>> undefined. My library builds using -std=gnu++11 just fine.
> 
> I guess this should be expected (correct) behaviour.
> 
> Neither off_t, nor _fsize_t, are strictly conforming ANSI types,
> so, if your project uses them, you shouldn't be compiling with an
> option which requires __STRICT_ANSI__ conformity checking, (as
> -std=c++11 does).

That said, if you've properly included non-ANSI <sys/types.h>, you
should certainly get a typedef for Microsoft's ugly _off_t, and unless
you've defined _NO_OLDNAMES, you would be justified in expecting that
off_t would also be defined, irrespective of __STRICT_ANSI__.  The
attached patch addresses this anomaly.

Similarly, if you've included non-ANSI header <io.h>, either directly
or indirectly via any other non-ANSI header, then you might justifiably
expect Microsoft's _fsize_t to be defined, once again irrespective of
__STRICT_ANSI__; however, you should *not* expect it to be defined if
<io.h> is included indirectly via an ANSI header, such as <wchar.h>,
when __STRICT_ANSI__ is defined.  In fact, this is a subtle bug in
<io.h> itself: if <wchar.h> has already been included, before <io.h>
is otherwise included, then the typedef of _fsize_t is assumed to have
been seen already, and isn't repeated.  This assumption is valid, if
__STRICT_ANSI__ is *not* defined, but invalid when __STRICT_ANSI__ *is*
defined.  Thus, if you include <io.h> *before* <wchar.h>, you *will*
get a typedef for _fsize_t, irrespective of __STRICT_ANSI__, but if you
include <wchar.h> *before* <io.h>, (or any other non-ANSI header which
includes <io.h>), then you will *not* get a typedef for _fsize_t.  This
is just wrong, and is also addressed in the attached patch.  However,
if you expect to get the _fsize_t typedef by including <wchar.h>, but
without any other non-ANSI means of including <io.h>, then you will be
disappointed if __STRICT_ANSI__ is defined; this is by design, and is
correct behaviour.

One final point: since you are getting errors pertaining to off_t not
being defined, if you *have* included <sys/types.h>, then there *is* a
bug in your own source code; you are violating the POSIX.1 requirement
that you ensure that _POSIX_C_SOURCE is appropriately defined.  MinGW
will define this for you, but *only* when __STRICT_ANSI__ is *not*
defined; if you compile with an option which implies __STRICT_ANSI__,
then the onus falls on *you* to ensure that _POSIX_C_SOURCE is defined,
*before* you include any POSIX.1 header, such as <sys/types.h>, to get
access to POSIX.1 features, such as non-ANSI types, of which off_t is
one.  Compliance with this POSIX.1 requirement would have made off_t
compilable, even with -std=c++11, and without the attached patch.

- -- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJX/9aFAAoJEMCtNsY0flo/urUP/3KQmrUItA1SsXK3EtoveDps
jx6jTmeyvwT0zPAG5fJ5ITR0ytMNd7Dtb65ET/pehDPNNZRhUSrE2Lqd+uNqPXra
HHACRscWVIOQLEuHFw4g7/VkUKZR1mYX36vN6q/TcHTz9f4BqoEttOIJDhh8o3LC
3dIHia2UTINPgGCZcBs2cgRz1kPozZeAVVIMlQoC63RPvzZQZ5MaUfrCNQWTaRdx
cTQ/So9CBLKFYDHF5qswtZQIqIolC+f9JOwC8YshyyUWo/HjOlojHi8HiIbPy03c
JVTXXZGbN1HIQISGdPwwr2bOXWiF10HVZgh7q7Mh57KSnfq0GVVthszFYbYX6a6k
pj6gHR+QhLARD3r/4Wm11UGBtdl3We9Uga4rhG18k+9LxWpXufzK818BPQEesI8+
af/Cf1RuhucM5dTQYj0DVhNvb5j3AwdeQAenHHs5eDL7wsOxxhzcLSRya7Ilh/QG
7OZ/RPmwIJuD4eX9ph59TUmN4e7yWxNxuNTswpUdHWSWhFoOenDJhAJawC1oUO1f
IPts4WqEjoETr2BJWDyjoW6IDMIyA/6sM0E5+Tuv1DJkOvhvLVuT9ZqLHc8bwYUs
xwsrkHvDIBWvdTuENNxcnc7gnKUmvmnMk9jiAQG2uJFVFbJIUSGcTSB086PnByzL
szOTmh95vFumVwEAJv5T
=LAee
-----END PGP SIGNATURE-----
# HG changeset patch
# Parent 433be73ef523893c6446a7ab0625e502edbe5a21

diff --git a/mingwrt/include/io.h b/mingwrt/include/io.h
--- a/mingwrt/include/io.h
+++ b/mingwrt/include/io.h
@@ -94,14 +94,14 @@
 #define FILENAME_MAX	(260)
 
 /* We must define _fsize_t, but some compilers (including GCC prior to
  * version 4.0), may choke if we try to do so more than once...
  */
-#if ! (defined _IO_H && defined _WCHAR_H)
+#if ! (defined _IO_H && defined _WCHAR_H) || defined __STRICT_ANSI__
  /* ...so DO NOT define it during direct <io.h> inclusion, (i.e. _IO_H
   * is defined), if <wchar.h> has already caused it to be defined, (i.e.
-  * _WCHAR_H is ALSO defined).
+  * _WCHAR_H is ALSO defined, but __STRICT_ANSI__ is NOT).
   */
 typedef	unsigned long	_fsize_t;
 #endif	/* ! (_IO_H && _WCHAR_H) */
 
 /* Functions for searching for files: _findfirst() sets errno to ENOENT,
diff --git a/mingwrt/include/sys/types.h b/mingwrt/include/sys/types.h
--- a/mingwrt/include/sys/types.h
+++ b/mingwrt/include/sys/types.h
@@ -64,19 +64,21 @@
  /* The POSIX off_t typedef is uglified, by Microsoft, as _off_t;
   * ensure that we provide support for the Microsoft form...
   */
   typedef __off32_t  _off_t;
 
-# if _POSIX_C_SOURCE
+# if _POSIX_C_SOURCE || ! defined _NO_OLDNAMES
   /* ...but note that this form should ALWAYS be preferred when
-   * compiling POSIX compatible source code.
+   * compiling POSIX compatible source code, and should also be
+   * made generally available unless Microsoft's old names have
+   * been suppressed, (by defining _NO_OLDNAMES).
    */
   typedef _off_t  off_t;
 # endif
 # if __GNUC__ < 4
   /* Some compilers, including GCC prior to v4, may get upset
-   * if we try to specifiy these typedefs more than once.
+   * if we try to specify these typedefs more than once.
    */
 #  define __have_typedef_off_t
 # endif
 #endif
 #undef __need_off_t
@@ -96,11 +98,11 @@
   typedef __off64_t  off64_t;
 # endif
 
 # if __GNUC__ < 4
   /* Some compilers, including GCC prior to v4, may get upset
-   * if we try to specifiy these typedefs more than once.
+   * if we try to specify these typedefs more than once.
    */
 #  define __have_typedef___off64_t
 # endif
 #endif
 #undef __need___off64_t
@@ -110,19 +112,21 @@
  /* POSIX ssize_t typedef, uglified by Microsoft as _ssize_t; ensure
   * that we support the Microsoft form...
   */
   typedef int  _ssize_t;
 
-# if _POSIX_C_SOURCE
+# if _POSIX_C_SOURCE || ! defined _NO_OLDNAMES
   /* ...but note that this form should ALWAYS be preferred when
-   * compiling POSIX compatible source code.
+   * compiling POSIX compatible source code, and should also be
+   * made generally available unless Microsoft's old names have
+   * been suppressed, (by defining _NO_OLDNAMES).
    */
   typedef _ssize_t  ssize_t;
 # endif
 # if __GNUC__ < 4
   /* Some compilers, including GCC prior to v4, may get upset
-   * if we try to specifiy these typedefs more than once.
+   * if we try to specify these typedefs more than once.
    */
 #  define __have_typedef_ssize_t
 # endif
 #endif
 #undef __need_ssize_t
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe