Skip to content

Commit 6ff7c84

Browse files
lvanassexiaoxiang781216
authored andcommitted
Doc: Migrate Put special stuff in NuttX header files
Migrate the page "Why can't I put my special stuff in NuttX header files?" page (https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629466) to the official wiki. Signed-off-by: Ludovic Vanasse <[email protected]>
1 parent 2d6df43 commit 6ff7c84

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

Documentation/guides/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ Guides
4141
armv7m_runtimestackcheck.rst
4242
disabling_stackdumpdebug.rst
4343
include_files_board_h.rst
44+
specialstuff_in_nuttxheaderfiles.rst
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
=======================================================
2+
Why can't I put my special stuff in NuttX header files?
3+
=======================================================
4+
5+
.. warning::
6+
Migrated from: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629466
7+
8+
The Problem
9+
===========
10+
11+
I am very picky about what goes into NuttX header files. I don't accept
12+
non-standardized changes to go into them just to permit external code to
13+
compile; nor do I accept changes that imply something is implemented in
14+
NuttX when it is not (although there are cases like that in the header
15+
files now).
16+
17+
* But I want to use `newlib` logic that depends on certain definitions on the
18+
Nuttx header files!
19+
* But I am trying to compile an application that depends on non-standard
20+
declarations in header files! Or prototypes for functions that are not
21+
provided by NuttX! Or types that are not used by NuttX!
22+
23+
You will find that I am very stubborn on this subject and you will be wasting
24+
your time and energy if you try to get kruft included into NuttX header files
25+
for your personal purposes.
26+
27+
A Work-Around
28+
=============
29+
30+
But there is a work-around for my pickiness and stubborn-ness (at least for
31+
compilers like GCC that support the GNU extensions). Let's suppose you wanted
32+
to add this definition:
33+
34+
.. code-block:: c
35+
36+
#define I_AM_A_NERD true
37+
38+
to the standard ``time.h`` header file. You submitted a patch to do this and
39+
I refused it. Now what?
40+
41+
While I refuse to put non-standard or useless stuff in NuttX header files,
42+
there are ways to work around this. Suppose that you create a directory
43+
called ``myincludes/`` and in your ``myincludes/`` directory is a header called
44+
``time.h``. This ``time.h`` header file consists of:
45+
46+
.. code-block:: C
47+
48+
#define I_AM_A_NERD true
49+
#include_next <time.h>
50+
51+
Then in your ``CFLAGS``, you use an ``-isystem`` setting to include header
52+
files from ``myincludes/`` before any header files from the NuttX ``include/``
53+
directory. Then when your application includes ``time.h``, the version of
54+
``time.h`` in ``myincludes/`` is the one that will be included. That version
55+
will define ``I_AM_A_NERD`` as you want and then include the next file named
56+
``time.h`` in the compiler's include path. That file will be the standard
57+
``time.h`` header file that is provided in the NuttX ``include/`` directory
58+
59+
In this way you an append or modify any of the NuttX header files to suit
60+
your own purposes without my having to accept changes that I do not want
61+
into the NuttX repository.
62+
63+
When Does It Make Sense?
64+
========================
65+
66+
When does it make sense to add new definitions, types, and function prototypes
67+
to the NuttX header files? Only under the following conditions:
68+
69+
* The changes are standard and specified in OpenGroup.org
70+
* The changes are provided by a patch that includes the full, verified
71+
implementation of the feature that uses the types and implements the
72+
functions.

0 commit comments

Comments
 (0)