From 9f2e6762930506d66a0d3c5ed81eac5b240b3a31 Mon Sep 17 00:00:00 2001 From: Keith Marshall Date: Mon, 28 Mar 2016 18:10:58 +0100 Subject: [PATCH] Factor out vs. duplicate declarations. --- mingwrt/ChangeLog | 14 ++++++++++++++ mingwrt/include/direct.h | 37 ++++++++++++++++++++++++++++--------- mingwrt/include/wchar.h | 25 +++++++++++++------------ 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog index e92239d..2033a18 100644 --- a/mingwrt/ChangeLog +++ b/mingwrt/ChangeLog @@ -1,3 +1,17 @@ +2016-03-28 Keith Marshall + + Factor out vs. duplicate declarations. + + * include/direct.h: Conditionally partition it, such that... + [__WCHAR_H_SOURCED__] (_DIRECT_H): Do not define it; declare only... + (_wchdir, wchar_t, wchar_t, _wmkdir, _wrmdir): ...these, otherwise... + [!__WCHAR_H_SOURCED__] (_DIRECT_H): Define it; expose all content. + (_WDIRECT_DEFINED): Never define it; delete all references. + + * include/wchar.h (_WDIRECT_DEFINED): Delete all references. + (_wchdir, wchar_t, wchar_t, _wmkdir, _wrmdir): Delete prototypes; + selectively #include to reproduce them. + 2016-03-26 Keith Marshall Factor out vs. duplicate declarations. diff --git a/mingwrt/include/direct.h b/mingwrt/include/direct.h index 0a10b41..3954033 100644 --- a/mingwrt/include/direct.h +++ b/mingwrt/include/direct.h @@ -32,6 +32,14 @@ */ #ifndef _DIRECT_H #pragma GCC system_header + +/* In addition to inclusion in its own right, this header supports + * selective inclusion by ; thus... + */ +#ifndef __WCHAR_H_SOURCED__ + /* ...we defer definition of the normal multiple inclusion guard, + * until we know that this is NOT a selective inclusion request. + */ #define _DIRECT_H #define __DIRECT_H_SOURCED__ @@ -45,32 +53,43 @@ #include #undef __DIRECT_H_SOURCED__ +#endif /* !__WCHAR_H_SOURCED__ */ + #ifndef RC_INVOKED _BEGIN_C_DECLS -/* Functions for manipulating disk drive selection. +#ifdef _DIRECT_H +/* Functions for manipulating disk drive selection; these are declared + * only when is included in its own right. */ _CRTIMP __cdecl __MINGW_NOTHROW int _getdrive (void); _CRTIMP __cdecl __MINGW_NOTHROW unsigned long _getdrives(void); _CRTIMP __cdecl __MINGW_NOTHROW int _chdrive (int); _CRTIMP __cdecl __MINGW_NOTHROW char *_getdcwd (int, char*, int); -/* The following group of functions are available only within - * MSVCRT.DLL, (i.e. they are NOT provided by CRTDLL.DLL); they - * are also declared in , hence avoid declaring them a - * second time. - */ -#if defined __MSVCRT__ && ! defined _WDIRECT_DEFINED +#endif /* _DIRECT_H */ +/* The following group of function prototypes are to be declared + * either when including in its own right, or when it + * is included selectively by ; however... + */ +#if defined __MSVCRT__ && ! (defined _DIRENT_H && defined _WCHAR_H) + /* + * ...they are available only within MSVCRT.DLL, (i.e. they are + * NOT provided by CRTDLL.DLL), and if both _DIRENT_H and _WCHAR_H + * are already defined, by the time we get to here, then this must + * be an inclusion of in its own right, AFTER they have + * already been declared on behalf of ; there is no need + * to declare them again. + */ _CRTIMP __cdecl __MINGW_NOTHROW int _wchdir (const wchar_t *); _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetcwd (wchar_t *, int); _CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetdcwd (int, wchar_t *, int); _CRTIMP __cdecl __MINGW_NOTHROW int _wmkdir (const wchar_t *); _CRTIMP __cdecl __MINGW_NOTHROW int _wrmdir (const wchar_t *); -#define _WDIRECT_DEFINED -#endif /* __MSVCRT__ && !_WDIRECT_DEFINED */ +#endif /* __MSVCRT__ && ! (defined _DIRENT_H && defined _WCHAR_H) */ _END_C_DECLS diff --git a/mingwrt/include/wchar.h b/mingwrt/include/wchar.h index 0828853..47c9c22 100644 --- a/mingwrt/include/wchar.h +++ b/mingwrt/include/wchar.h @@ -174,6 +174,19 @@ * long double wcstold (const wchar_t *restrict, wchar_t **restrict); * * + * while from... + */ +#include +/* ...we obtain prototypes for each of the following functions, + * (none of which are available when using CRTDLL.DLL): + * + * int _wchdir (const wchar_t *); + * wchar_t *_wgetcwd (wchar_t *, int); + * wchar_t *_wgetdcwd (int, wchar_t *, int); + * int _wmkdir (const wchar_t *); + * int _wrmdir (const wchar_t *); + * + * * Again, in similar fashion, from... */ #include @@ -487,18 +500,6 @@ _CRTALIAS int __cdecl __MINGW_NOTHROW _wfindnexti64 (long _v1, struct _wfinddat #define _WIO_DEFINED #endif /* _WIO_DEFINED */ -#ifndef _WDIRECT_DEFINED -/* Also in direct.h */ -#ifdef __MSVCRT__ -_CRTIMP int __cdecl __MINGW_NOTHROW _wchdir (const wchar_t*); -_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetcwd (wchar_t*, int); -_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetdcwd (int, wchar_t*, int); -_CRTIMP int __cdecl __MINGW_NOTHROW _wmkdir (const wchar_t*); -_CRTIMP int __cdecl __MINGW_NOTHROW _wrmdir (const wchar_t*); -#endif /* __MSVCRT__ */ -#define _WDIRECT_DEFINED -#endif /* _WDIRECT_DEFINED */ - #ifndef _STAT_DEFINED /* * The structure manipulated and returned by stat and fstat. -- 2.11.0