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

commit 986fd479b7cc9e3c34421bb436d6cbc133a37f91
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 27 17:17:43 2026 +0100

    Documentation: Declare global data with extern.
    
    The coding standard asked each header to define EXTERN for its global
    data and to undefine it at its end.  The headers now declare their data
    with plain extern inside their extern "C" block, and the definition is
    gone.  Describe that in the template: the data declarations use extern,
    and a header does not define a macro such as EXTERN, which would change
    a name that a program can use.
    
    The NSH builtin page showed the REGISTER macro of nuttx-apps writing
    "EXTERN int main(...)"; it writes the prototype without EXTERN.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 Documentation/applications/nsh/builtin.rst  |  2 +-
 Documentation/contributing/coding_style.rst | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/Documentation/applications/nsh/builtin.rst 
b/Documentation/applications/nsh/builtin.rst
index 1ea431bc2ec..220974db7f2 100644
--- a/Documentation/applications/nsh/builtin.rst
+++ b/Documentation/applications/nsh/builtin.rst
@@ -146,7 +146,7 @@ that in ``apps/examples/hello/Makefile`` is abstracted 
below:
         define REGISTER
             @echo "Register: $1"
             @echo "{ \"$1\", $2, $3, $4 }," >> 
"$(APPDIR)/builtin/builtin_list.h"
-            @echo "EXTERN int $4(int argc, char *argv[]);" >> 
"$(APPDIR)/builtin/builtin_proto.h"
+            @echo "int $4(int argc, char *argv[]);" >> 
"$(APPDIR)/builtin/builtin_proto.h"
         endef
 
      When this macro runs, you will see the output in the build
diff --git a/Documentation/contributing/coding_style.rst 
b/Documentation/contributing/coding_style.rst
index 38549565cb1..c2c39f21273 100644
--- a/Documentation/contributing/coding_style.rst
+++ b/Documentation/contributing/coding_style.rst
@@ -2643,15 +2643,14 @@ C Header File Structure
   ****************************************************************************/
 
   #ifdef __cplusplus
-  #define EXTERN extern "C"
   extern "C"
   {
-  #else
-  #define EXTERN extern
   #endif
 
 *All data declarations with global scope appear here, preceded by the
-definition* ``EXTERN``.
+keyword* ``extern``.  *They are inside the* ``extern "C"`` *block, so they
+have C linkage also in C++.  Do not define a macro such as* ``EXTERN``
+*for them: a header must not change a name that a program can use.*
 
 .. code-block:: c
 
@@ -2707,12 +2706,10 @@ preceded by a function header similar to the above.*
   ****************************************************************************/
 
 *All global functions in the file are prototyped here. The keyword*
-``extern`` *or the definition* ``EXTERN`` *are never used with function
-prototypes.*
+``extern`` *is never used with function prototypes.*
 
 .. code-block:: c
 
-   #undef EXTERN
    #ifdef __cplusplus
    }
    #endif

Reply via email to