You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "casaroli (via GitHub)" <gi...@apache.org> on 2026/10/17 21:16:19 UTC
[PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
casaroli opened a new pull request, #20747:
URL: https://github.com/apache/nuttx/pull/20747
## Summary
NuttX public headers define names that are not in any standard: `OK`, `ERROR`, `set_errno`, `get_errno`, `zalloc`, `O_TEXT`, and `weak_alias`, `visibility_hidden`, `visibility_default` and `unused_data` from `nuttx/compiler.h`. A ported program that defines one of these names itself does not compile.
This PR adds `NUTTX_NO_EXTENSIONS`, in the same form as the existing `NUTTX_NO_GETOPT_MACROS`. When a program defines it before its first include, the public headers do not define these names.
- The first two commits stop the public headers from using `OK` and `ERROR` themselves: `PTHREAD_CANCELED`, `thrd_success` and `thrd_error`, and the inline functions of `nuttx/mutex.h` and `nuttx/signal.h`, now use the plain values. The values do not change.
- The third commit adds the macro.
- The last commit adds a section to `Documentation/os/libs/libc/index.rst` that describes `NUTTX_NO_GETOPT_MACROS` (not documented before) and `NUTTX_NO_EXTENSIONS`.
`CODE`, `builtin_function` and `object_size` stay visible, because public prototypes and inline functions use them.
## Impact
Nothing changes when the macro is not defined.
## Testing
A test program defines `NUTTX_NO_EXTENSIONS` and then its own `OK`/`ERROR` enum, a static `zalloc()`, `set_errno()`/`get_errno()` functions and the other names. On master it gives 15 compile errors; with this PR it compiles with `-Werror` and passes on `qemu-armv8a:knsh`. Without the macro, a program that uses the NuttX names compiles with `-Werror` on master and with this PR.
Each public header compiles alone, with and without the macro, on `lm3s6965-ek:qemu-flat` and `qemu-armv8a:knsh`, with the same results as master. All `include/cxx` headers compile with g++ with and without the macro.
`ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: Exiting with status 0`. `tools/checkpatch.sh -c -u -m -g` passes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#discussion_r4306028981
##########
include/errno.h:
##########
@@ -45,6 +45,10 @@
*/
#define errno *__errno()
+
+/* Not with NUTTX_NO_EXTENSIONS, see nuttx/compiler.h */
+
+#ifndef NUTTX_NO_EXTENSIONS
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
#define set_errno(e) \
Review Comment:
ditto
##########
include/errno.h:
##########
@@ -64,6 +68,7 @@
while (0)
#endif
#define get_errno() errno
Review Comment:
indent
##########
Documentation/os/libs/libc/index.rst:
##########
@@ -70,6 +70,26 @@ directory::
misc - Nonstandard "glue" logic, nuttx/debug.h, crc32.h, dirent.h
+Non-standard Names in the Headers
+=================================
+
+Some headers define names for the OS that C and POSIX do not reserve.
+A portable program that uses such a name for its own purpose can define
+one of these macros before its first ``#include``:
+
+``NUTTX_NO_GETOPT_MACROS``
Review Comment:
could we unify NUTTX_NO_GETOPT_MACROS and NUTTX_NO_EXTENSIONS into one macro?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#discussion_r4307632818
##########
Documentation/os/libs/libc/index.rst:
##########
@@ -70,6 +70,26 @@ directory::
misc - Nonstandard "glue" logic, nuttx/debug.h, crc32.h, dirent.h
+Non-standard Names in the Headers
+=================================
+
+Some headers define names for the OS that C and POSIX do not reserve.
+A portable program that uses such a name for its own purpose can define
+one of these macros before its first ``#include``:
+
+``NUTTX_NO_GETOPT_MACROS``
Review Comment:
ok, let's keep the current naming and unify all skipping of POSIX macro definition to a common option when we find another macro need skipped.
let's fix other comment and then merge this patch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#discussion_r4307632818
##########
Documentation/os/libs/libc/index.rst:
##########
@@ -70,6 +70,26 @@ directory::
misc - Nonstandard "glue" logic, nuttx/debug.h, crc32.h, dirent.h
+Non-standard Names in the Headers
+=================================
+
+Some headers define names for the OS that C and POSIX do not reserve.
+A portable program that uses such a name for its own purpose can define
+one of these macros before its first ``#include``:
+
+``NUTTX_NO_GETOPT_MACROS``
Review Comment:
ok, let's keep the current naming and unify all skipping of POSIX macro definition to a common option when we find another macro need skipped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on code in PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#discussion_r4306737121
##########
Documentation/os/libs/libc/index.rst:
##########
@@ -70,6 +70,26 @@ directory::
misc - Nonstandard "glue" logic, nuttx/debug.h, crc32.h, dirent.h
+Non-standard Names in the Headers
+=================================
+
+Some headers define names for the OS that C and POSIX do not reserve.
+A portable program that uses such a name for its own purpose can define
+one of these macros before its first ``#include``:
+
+``NUTTX_NO_GETOPT_MACROS``
Review Comment:
I felt to keep `NUTTX_NO_GETOPT_MACROS` separate because it is for specific posix names, while `NUTTX_NO_EXTENSIONS` would be for any generic names.
If you prefer we can either:
1. keep `NUTTX_NO_GETOPT_MACROS` separate
2. gate `geotopt` on `NUTTX_NO_EXTENSIONS` instead
3. set `NUTTX_NO_GETOPT_MACROS` if `NUTTX_NO_EXTENSIONS` is set.
I prefer 1, but it is your call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #20747:
URL: https://github.com/apache/nuttx/pull/20747
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli commented on code in PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#discussion_r4307755273
##########
include/errno.h:
##########
@@ -64,6 +68,7 @@
while (0)
#endif
#define get_errno() errno
Review Comment:
Done.
##########
include/errno.h:
##########
@@ -45,6 +45,10 @@
*/
#define errno *__errno()
+
+/* Not with NUTTX_NO_EXTENSIONS, see nuttx/compiler.h */
+
+#ifndef NUTTX_NO_EXTENSIONS
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
#define set_errno(e) \
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] include: Add NUTTX_NO_EXTENSIONS to keep non-standard names free. [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20747:
URL: https://github.com/apache/nuttx/pull/20747#issuecomment-6241314850
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=9292369f67348779a0821f8e8a470f4db5b0c52e&base=d2ce23c49ebfdd9f5ed541a08493eb62c1aa20a5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org