Identifiants » Historique » Version 14
Patrice Nadeau, 2024-01-27 15:30
| 1 | 6 | Patrice Nadeau | # Objets |
|---|---|---|---|
| 2 | 3 | Patrice Nadeau | |
| 3 | ## Règles |
||
| 4 | |||
| 5 | 2 | Patrice Nadeau | 1. Comportent au maximum **31** caractères : |
| 6 | 1. Lettres minuscules |
||
| 7 | 1. Nombres |
||
| 8 | 1. Trait de soulignement |
||
| 9 | 1 | Patrice Nadeau | 1. Si plusieurs mots sont utilisés, ils sont séparées par des traits de soulignement |
| 10 | 14 | Patrice Nadeau | 1. si la visibilité n'est que locale, le modificateur `static` doit être utilisé |
| 11 | 2 | Patrice Nadeau | 1. Les objets ne devant plus être utilisés, DOIVENT générer un message lors de la compilation (`-Wall`) si un appel est effectué. |
| 12 | 1. Les attributs`deprecated` ou `unavailable` DOIVENT être ajoutés à la déclaration. |
||
| 13 | 7 | Patrice Nadeau | 1. Les commentaires Doxygen suivants doivent être ajoutés : |
| 14 | 1. `@deprecated` : |
||
| 15 | 1. `@since` : |
||
| 16 | 1 | Patrice Nadeau | |
| 17 | 3 | Patrice Nadeau | ## Exemple |
| 18 | 1 | Patrice Nadeau | ``` c |
| 19 | /** |
||
| 20 | * @brief OldFunction |
||
| 21 | * @deprecated Utiliser NewFunction à la place |
||
| 22 | * @since Version x.x.xx |
||
| 23 | */ |
||
| 24 | int OldFunction(void) __attribute__((deprecated)); |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @brief OldFunction |
||
| 28 | * @deprecated Utiliser NewFunction à la place |
||
| 29 | * @since Version x.x.xx |
||
| 30 | */ |
||
| 31 | int OldFunction(void) __attribute__((unavailable)); |
||
| 32 | 4 | Patrice Nadeau | |
| 33 | /** |
||
| 34 | * @brief MACRO1 |
||
| 35 | * @deprecated Utiliser NEWMACRO à la place |
||
| 36 | 1 | Patrice Nadeau | * @since Version x.x.xx |
| 37 | */ |
||
| 38 | #define MACRO1 43 |
||
| 39 | #pragma GCC poison MACRO1 |
||
| 40 | 14 | Patrice Nadeau | |
| 41 | /** |
||
| 42 | * @brief Fonction locale |
||
| 43 | * @return Une valeur |
||
| 44 | */ |
||
| 45 | static int local_func(void) { |
||
| 46 | ... |
||
| 47 | return 0; |
||
| 48 | } |
||
| 49 | 1 | Patrice Nadeau | ``` |
| 50 | 5 | Patrice Nadeau | |
| 51 | ## Justification |
||
| 52 | * Linux kernel coding style : <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#naming> |
||
| 53 | * GNU Coding Standards <https://www.gnu.org/prep/standards/html_node/Writing-C.html#Writing-C> |
||
| 54 | * Embedded C Coding Standard : <https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard> |
||
| 55 | 1 | Patrice Nadeau | |
| 56 | ### Déclarations locales |
||
| 57 | |||
| 58 | Une déclaration n’ayant qu’une visibilité locale DOIT : |
||
| 59 | * Être de classe `static` |
||
| 60 | |||
| 61 | Exemple: |
||
| 62 | ``` c |
||
| 63 | /** |
||
| 64 | * @brief Fonction locale |
||
| 65 | * @return Une valeur |
||
| 66 | */ |
||
| 67 | static int local_func(void) { |
||
| 68 | ... |
||
| 69 | return 0; |
||
| 70 | } |
||
| 71 | ``` |