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 1738e6fdf1c sys/types.h: move CONFIG_INIT_ENTRYPOINT declaration out 
of sys/types.h
1738e6fdf1c is described below

commit 1738e6fdf1c7a72ff27541f7c0018f4a903746f1
Author: Sarthak Pandey <[email protected]>
AuthorDate: Tue Oct 20 09:53:28 2026 +0530

    sys/types.h: move CONFIG_INIT_ENTRYPOINT declaration out of sys/types.h
    
    Commit 321105a changed the prototype of main() in crt0.c to
    int main(int argc, char *argv[], char *envp[]).
    
    When CONFIG_INIT_ENTRYPOINT="main" (the default), include/sys/types.h
    declared int main(int argc, FAR char *argv[]), which conflicts with the
    3-argument declaration in crt0.c during compilation:
    
    error: conflicting types for 'main'; have 'int(int, char **, char **)'
    note: previous declaration of 'main' with type 'int(int, char **)'
    
    Furthermore, sys/types.h is a POSIX type header and should not declare
    application entry points, which pollutes the global namespace.
    
    This commit moves the prototype declaration of CONFIG_INIT_ENTRYPOINT
    from include/sys/types.h to sched/init/nx_bringup.c (for flat builds)
    and include/nuttx/userspace.h (for protected builds) where the entry
    point is actually referenced.
    
    Fixes: #20823
    Signed-off-by: Sarthak Pandey <[email protected]>
---
 include/nuttx/userspace.h |  6 ++++++
 include/sys/types.h       | 23 -----------------------
 sched/init/nx_bringup.c   |  4 ++++
 3 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h
index 6b7d3363036..e85a2a5e752 100644
--- a/include/nuttx/userspace.h
+++ b/include/nuttx/userspace.h
@@ -139,6 +139,12 @@ extern "C"
  * Public Function Prototypes
  ****************************************************************************/
 
+/* This entry point must be supplied by the application */
+
+#ifdef CONFIG_INIT_ENTRYPOINT
+int CONFIG_INIT_ENTRYPOINT(int argc, FAR char *argv[]);
+#endif
+
 #undef EXTERN
 #ifdef __cplusplus
 }
diff --git a/include/sys/types.h b/include/sys/types.h
index 9dedd7d7092..239bebfe7fc 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -366,29 +366,6 @@ typedef struct pthread_once_s pthread_once_t;
 #  define __PTHREAD_ONCE_T_DEFINED 1
 #endif
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/* This entry point must be supplied by the application */
-
-#ifdef CONFIG_INIT_ENTRYPOINT
-int CONFIG_INIT_ENTRYPOINT(int argc, FAR char *argv[]);
-#endif
-
-#undef EXTERN
-#if defined(__cplusplus)
-}
-#endif
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __INCLUDE_SYS_TYPES_H */
diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c
index 79e6f2a1852..66e297e31b5 100644
--- a/sched/init/nx_bringup.c
+++ b/sched/init/nx_bringup.c
@@ -86,6 +86,10 @@
 #      error CONFIG_INIT_ENTRYPOINT must be defined
 #    endif
 
+#    ifndef CONFIG_BUILD_PROTECTED
+int CONFIG_INIT_ENTRYPOINT(int argc, FAR char *argv[]);
+#    endif
+
 #  elif defined(CONFIG_INIT_FILE)
   /* Initialize by running an initialization program in the file system.
    * Presumably the user has configured a board initialization function

Reply via email to