OSDN Git Service

Factor out <wchar.h> vs. <direct.h> duplicate declarations.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 28 Mar 2016 17:10:58 +0000 (18:10 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Mon, 28 Mar 2016 17:10:58 +0000 (18:10 +0100)
mingwrt/ChangeLog
mingwrt/include/direct.h
mingwrt/include/wchar.h

index e92239d..2033a18 100644 (file)
@@ -1,3 +1,17 @@
+2016-03-28  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Factor out <wchar.h> vs. <direct.h> 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 <direct.h> to reproduce them.
+
 2016-03-26  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Factor out <direct.h> vs. <dos.h> duplicate declarations.
index 0a10b41..3954033 100644 (file)
  */
 #ifndef _DIRECT_H
 #pragma GCC system_header
+
+/* In addition to inclusion in its own right, this header supports
+ * selective inclusion by <wchar.h>; 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__
 #include <dos.h>
 
 #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 <direct.h> 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 <wchar.h>, 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 <dirent.h> in its own right, or when it
+ * is included selectively by <wchar.h>; 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 <dirent.h> in its own right, AFTER they have
+  * already been declared on behalf of <wchar.h>; 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
 
index 0828853..47c9c22 100644 (file)
  *  long double wcstold (const wchar_t *restrict, wchar_t **restrict);
  *
  *
+ * while from...
+ */
+#include <direct.h>
+/* ...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 <time.h>
@@ -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.