This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 246a829216b include/sys/types.h: Define wchar_t before including 
<stdint.h>.
246a829216b is described below

commit 246a829216bbec847a725289f57028fef1ac2980
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 9 10:46:55 2026 +0200

    include/sys/types.h: Define wchar_t before including <stdint.h>.
    
    <stddef.h> includes <sys/types.h>, which includes <stdint.h>, and only
    then defined wchar_t.  A program may have its own <stdint.h> that
    includes <inttypes.h> (portability layers do this).  <inttypes.h>
    includes <stddef.h>, which is already being read and adds nothing, and
    then declares wcstoimax() with wchar_t, which does not exist yet:
    
      inttypes.h: error: unknown type name 'wchar_t'
    
    Include <arch/types.h> and define wchar_t before <stdint.h>.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/sys/types.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/sys/types.h b/include/sys/types.h
index 31e8410e789..67c1dcf1375 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -31,6 +31,17 @@
 #include <nuttx/compiler.h>
 
 #ifndef __ASSEMBLY__
+#  include <arch/types.h>
+
+/* Wide character type, defined before <stdint.h> is included: a program's
+ * own <stdint.h> may include <inttypes.h>, which uses wchar_t while this
+ * file is still being read.  wchar_t is a built-in type in C++.
+ */
+
+#  if !defined(__cplusplus)
+typedef _wchar_t     wchar_t;
+#  endif
+
 #  include <stdint.h>
 #endif
 
@@ -173,16 +184,6 @@ typedef int32_t      key_t;
 
 typedef intptr_t     ptrdiff_t;
 
-#if !defined(__cplusplus)
-/* Wide character types.  wchar_t is a built-in type in C++ and
- * its declaration here may cause compilation errors on some compilers.
- *
- * REVISIT: wchar_t belongs in stddef.h
- */
-
-typedef _wchar_t     wchar_t;
-#endif
-
 /* wint_t
  *   An integral type capable of storing any valid value of wchar_t, or WEOF.
  */

Reply via email to