Re: [PATCH 04/14] Set _O_BINARY as default fmode for both MinGW and MSVC
- From
Alexey Borzenkov <snaury@gmail.com>
- Date
- Sep 15, 2009, 18:40 UTC
- Message-ID
- <e2480c70909151140i26a8e748wf978145724d3fd55@mail.gmail.com>
- In-Reply-To
- <badc5d24387c28c752a45f75e8aec6bce64f81fe.1253021728.git.mstormo@gmail.com>
On Tue, Sep 15, 2009 at 5:44 PM, Marius Storm-Olsen <mstormo@gmail.com> wrote:
> +extern int _fmode;
Is it really needed? I might be wrong, but I thought _fmode needed a more complex declaration, at least on mingw, for which you are supposed to include stdlib.h. For example, for mingw, in stdlib.h, it is declared this way:
#if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME)
#ifdef __MSVCRT__ extern int* _imp___fmode; #define _fmode (*_imp___fmode) #else /* CRTDLL */ extern int* _imp___fmode_dll; #define _fmode (*_imp___fmode_dll) #endif
#else /* __DECLSPEC_SUPPORTED */
#ifdef __MSVCRT__ __MINGW_IMPORT int _fmode; #else /* ! __MSVCRT__ */ __MINGW_IMPORT int _fmode_dll; #define _fmode _fmode_dll #endif /* ! __MSVCRT__ */
#endif /* __DECLSPEC_SUPPORTED */
As you can see it is a little more complex than a simple extern (e.g. it uses __declspec(dllimport) when it is supported, and a bit of manual dereferencing otherwise). So maybe you would just include stdlib.h and use definition from there?