Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
include/README@2:d9745be6c253, 2022-08-04 (annotated)
- Committer:
- fionalin
- Date:
- Thu Aug 04 15:14:29 2022 -0400
- Revision:
- 2:d9745be6c253
hehe forgot to commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fionalin | 2:d9745be6c253 | 1 | |
fionalin | 2:d9745be6c253 | 2 | This directory is intended for project header files. |
fionalin | 2:d9745be6c253 | 3 | |
fionalin | 2:d9745be6c253 | 4 | A header file is a file containing C declarations and macro definitions |
fionalin | 2:d9745be6c253 | 5 | to be shared between several project source files. You request the use of a |
fionalin | 2:d9745be6c253 | 6 | header file in your project source file (C, C++, etc) located in `src` folder |
fionalin | 2:d9745be6c253 | 7 | by including it, with the C preprocessing directive `#include'. |
fionalin | 2:d9745be6c253 | 8 | |
fionalin | 2:d9745be6c253 | 9 | ```src/main.c |
fionalin | 2:d9745be6c253 | 10 | |
fionalin | 2:d9745be6c253 | 11 | #include "header.h" |
fionalin | 2:d9745be6c253 | 12 | |
fionalin | 2:d9745be6c253 | 13 | int main (void) |
fionalin | 2:d9745be6c253 | 14 | { |
fionalin | 2:d9745be6c253 | 15 | ... |
fionalin | 2:d9745be6c253 | 16 | } |
fionalin | 2:d9745be6c253 | 17 | ``` |
fionalin | 2:d9745be6c253 | 18 | |
fionalin | 2:d9745be6c253 | 19 | Including a header file produces the same results as copying the header file |
fionalin | 2:d9745be6c253 | 20 | into each source file that needs it. Such copying would be time-consuming |
fionalin | 2:d9745be6c253 | 21 | and error-prone. With a header file, the related declarations appear |
fionalin | 2:d9745be6c253 | 22 | in only one place. If they need to be changed, they can be changed in one |
fionalin | 2:d9745be6c253 | 23 | place, and programs that include the header file will automatically use the |
fionalin | 2:d9745be6c253 | 24 | new version when next recompiled. The header file eliminates the labor of |
fionalin | 2:d9745be6c253 | 25 | finding and changing all the copies as well as the risk that a failure to |
fionalin | 2:d9745be6c253 | 26 | find one copy will result in inconsistencies within a program. |
fionalin | 2:d9745be6c253 | 27 | |
fionalin | 2:d9745be6c253 | 28 | In C, the usual convention is to give header files names that end with `.h'. |
fionalin | 2:d9745be6c253 | 29 | It is most portable to use only letters, digits, dashes, and underscores in |
fionalin | 2:d9745be6c253 | 30 | header file names, and at most one dot. |
fionalin | 2:d9745be6c253 | 31 | |
fionalin | 2:d9745be6c253 | 32 | Read more about using header files in official GCC documentation: |
fionalin | 2:d9745be6c253 | 33 | |
fionalin | 2:d9745be6c253 | 34 | * Include Syntax |
fionalin | 2:d9745be6c253 | 35 | * Include Operation |
fionalin | 2:d9745be6c253 | 36 | * Once-Only Headers |
fionalin | 2:d9745be6c253 | 37 | * Computed Includes |
fionalin | 2:d9745be6c253 | 38 | |
fionalin | 2:d9745be6c253 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |