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 be3ebdcbb52f5284c2291949ff7dca68cae8a6fa
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 20 17:20:02 2026 +0200

    Documentation: NUTTX_NO_GETOPT_MACROS declares the getopt() variables.
    
    With NUTTX_NO_GETOPT_MACROS, <unistd.h> now declares optarg, opterr,
    optind and optopt as extern variables.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 Documentation/os/libs/libc/index.rst |  7 ++++---
 Documentation/os/scheduling/tls.rst  | 13 +++++++------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/Documentation/os/libs/libc/index.rst 
b/Documentation/os/libs/libc/index.rst
index 496938f68cd..c02a94a2ee1 100644
--- a/Documentation/os/libs/libc/index.rst
+++ b/Documentation/os/libs/libc/index.rst
@@ -80,9 +80,10 @@ one of these macros before its first ``#include``:
 
 ``NUTTX_NO_GETOPT_MACROS``
   ``unistd.h`` does not define ``optarg``, ``opterr``, ``optind`` and
-  ``optopt`` as macros.  getopt() keeps these values per task, so use
-  this only in a program that brings its own getopt() and its own
-  variables of these names.
+  ``optopt`` as macros; it declares them as ``extern`` variables, which
+  the program or another library defines.  getopt() keeps these values
+  per task, so use this only in a program that brings its own getopt()
+  and its own variables of these names.
 
 ``NUTTX_NO_EXTENSIONS``
   The headers do not define ``ERROR`` and ``OK`` (``sys/types.h``),
diff --git a/Documentation/os/scheduling/tls.rst 
b/Documentation/os/scheduling/tls.rst
index 7af1130c67e..075e9dddeec 100644
--- a/Documentation/os/scheduling/tls.rst
+++ b/Documentation/os/scheduling/tls.rst
@@ -142,12 +142,13 @@ program does not read.
 
 Such a program can define ``NUTTX_NO_GETOPT_MACROS``, for example with
 ``-DNUTTX_NO_GETOPT_MACROS`` in its ``CFLAGS``. ``<unistd.h>`` then does
-not define the four macros, and the program source does not change. Do not
-define it in a program that calls the ``getopt()`` of the C library: that
-``getopt()`` sets the per-task copies, not variables of the program. The
-C library has no variables with these names, so such a program does not
-compile or does not link unless it defines them, and then it reads values
-that ``getopt()`` did not set.
+not define the four macros; it declares them as the ``extern`` variables
+that POSIX specifies, in every build mode, and the program source does not
+change. Do not define it in a program that calls the ``getopt()`` of the C
+library: that ``getopt()`` sets the per-task copies, not variables of the
+program. The C library has no variables with these names, so such a
+program does not link unless it or another library defines them, and then
+it reads values that ``getopt()`` did not set.
 
 
 Unaligned TLS

Reply via email to