[Mingw-users] gcc 8.2.0: missing _fileno() for c++11

Keith Marshall keith****@users*****
Tue Jan 21 05:47:31 JST 2020


On 20/01/2020 20:22, Anton Shepelev wrote:
> Eli Zaretskii:
>> Doesn't -std=c++11 request strict ANSI C++?  _fileno is
>> non-ANSI, and thus isn't visible in a strict-ANSI
>> compilation.  I suggest to try the option -std=gnu++11
>> instead.
> 
> But you are right -- why should one expect a non-standard
> function or macro in a standard header if MinGW is not
> obliged to implement POSIX?  On the other hand, this worked
> with GCC 4.*...

GCC-4.x with what options?  Eli is 100% correct — -std=c++11 turns on
strict ANSI, (or more correctly ISO-C++), conformance checking, and
since fileno() is a POSIX.1 extension to ISO-C, (and _fileno() is a
Microsoft specific equivalent extension), if you request strict
ISO-C/ISO-C++ conformance checking, then either will be rightfully rejected.

> Since the project I am trying to build and contribute to is
> configured not to use the GNU extensions, I have to find
> another way of acessing fileno/_fileno.

But you are *already* depending on extensions, w.r.t. the standard of
conformance which you are demanding.  If you want extensions, whether
they be GNU or Microsoft, (or MinGW), don't specify "-std=c++11".  Why
do you need to do so, anyway?  GCC-8 compiles C++11 code by default,
without requiring *any* "-std=..." restriction.

> May I link it in manually from the MinGW library in which it *is* 
> implemented?

Of course.  You will get it from the default C-runtime library, but you
will need to explicitly declare it yourself.

> Or may I, perhaps, ask to to implement fileno as a favour?
No.  Either don't specify strict standards conformance checking, for a
standard which you are violating anyway, or provide your own extended
API declarations.

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200120/d5faeaaa/attachment.sig>


More information about the MinGW-Users mailing list