Wiki » Historique » Version 39
Patrice Nadeau, 2023-08-16 20:02
| 1 | 1 | Patrice Nadeau | # Règles de codage C |
|---|---|---|---|
| 2 | |||
| 3 | Le langage C, version C99 (ISO/IEC 9899:1999) utilisé avec le compilateur [GCC](https://gcc.gnu.org/). |
||
| 4 | |||
| 5 | > `gcc` n'est pas entièrement compatible avec le standard C99 (<https://gcc.gnu.org/c99status.html>). |
||
| 6 | |||
| 7 | --- |
||
| 8 | {{toc}} |
||
| 9 | |||
| 10 | ## Style |
||
| 11 | |||
| 12 | 6 | Patrice Nadeau | Le code DOIT : |
| 13 | 5 | Patrice Nadeau | * Être dans le style [K&R](https://fr.wikipedia.org/wiki/Style_d%27indentation#Style_K&R) avec la variante *one true brace style* (1TBS): |
| 14 | 1 | Patrice Nadeau | * L’indentation est de 4 espaces |
| 15 | * Le « backslash » est utilisé pour les lignes de plus de 80 caractères |
||
| 16 | * Une instruction par ligne |
||
| 17 | * Une espace avant et après un opérateur sauf pour les opérateurs « [unaires](https://fr.wikipedia.org/wiki/Op%C3%A9ration_unaire) » |
||
| 18 | |||
| 19 | Justification : |
||
| 20 | * [K&R](https://fr.wikipedia.org/wiki/Style_d%27indentation#Style_K&R) |
||
| 21 | 10 | Patrice Nadeau | * Prévient les erreurs lors d'ajout dans les boucles n'ayant qu'une instruction comme bloc |
| 22 | 1 | Patrice Nadeau | |
| 23 | Exemple : |
||
| 24 | ``` c |
||
| 25 | 4 | Patrice Nadeau | int fonction(void) { |
| 26 | 1 | Patrice Nadeau | int x; |
| 27 | if (var != 1) { |
||
| 28 | x = x + 1; |
||
| 29 | y++; |
||
| 30 | printf("This is a long\ |
||
| 31 | line that should be splitted"); |
||
| 32 | 2 | Patrice Nadeau | } else { |
| 33 | 1 | Patrice Nadeau | x--; |
| 34 | 3 | Patrice Nadeau | }; |
| 35 | 1 | Patrice Nadeau | return 0; |
| 36 | } |
||
| 37 | ``` |
||
| 38 | |||
| 39 | ### Langue |
||
| 40 | |||
| 41 | 34 | Patrice Nadeau | * Les fonctions, variables, constantes et `#define` DOIVENT être en [anglais américain](https://fr.wikipedia.org/wiki/Anglais_am%C3%A9ricain) |
| 42 | * Les commentaires et documentation DOIVENT être en français |
||
| 43 | |||
| 44 | Justifications : |
||
| 45 | 35 | Patrice Nadeau | * Support ASCII 7-bits |
| 46 | 34 | Patrice Nadeau | * Correspondance avec la fiche technique (datasheet) |
| 47 | * [Loi sur la langue officielle et commune du Québec, le français](https://www.publicationsduquebec.gouv.qc.ca/fileadmin/Fichiers_client/lois_et_reglements/LoisAnnuelles/fr/2022/2022C14F.PDF) |
||
| 48 | 1 | Patrice Nadeau | |
| 49 | ### Copyright |
||
| 50 | |||
| 51 | [BSD 2 clauses (FreeBSD)](https://opensource.org/license/bsd-2-clause/) |
||
| 52 | |||
| 53 | Copier dans un fichier `LICENSE.txt` |
||
| 54 | |||
| 55 | ### Doxygen |
||
| 56 | Logiciel [Doxygen](https://www.doxygen.nl/) utilisé pour générer la documentation à partir de commentaires spécialement formatés. |
||
| 57 | |||
| 58 | Chaque objet (fonctions, variables, etc.) DOIT être commenté/documenté : |
||
| 59 | * Dans le format [Javadoc](https://www.doxygen.nl/manual/docblocks.html) (/** */) |
||
| 60 | * Avant sa déclaration |
||
| 61 | 14 | Patrice Nadeau | * Les « décorations » sont faites avec la syntaxe Markdown |
| 62 | 1 | Patrice Nadeau | |
| 63 | Exemple : |
||
| 64 | ``` c |
||
| 65 | /** |
||
| 66 | 16 | Patrice Nadeau | * *italique*, **gras** |
| 67 | * `code en ligne` |
||
| 68 | 20 | Patrice Nadeau | * @remark Note non importante |
| 69 | * @note Note générale |
||
| 70 | * @attention Note importante |
||
| 71 | * @warning Note conséquence négative |
||
| 72 | 18 | Patrice Nadeau | * ``` |
| 73 | * code |
||
| 74 | * ``` |
||
| 75 | 17 | Patrice Nadeau | */ |
| 76 | 1 | Patrice Nadeau | ``` |
| 77 | |||
| 78 | ## Fichiers |
||
| 79 | Le nom des fichiers DOIT être composé de la manière suivante : |
||
| 80 | * En minuscule |
||
| 81 | * 8 caractères maximum |
||
| 82 | * L'extension est |
||
| 83 | * `.h` pour les fichiers d’entête |
||
| 84 | * `.c` pour les fichiers sources |
||
| 85 | * Contient une section Doxygen « file » |
||
| 86 | * Les fichier d’entête contiennent en plus |
||
| 87 | * Une section Doxygen « mainpage » |
||
| 88 | * Une définition macro DOIT être faite pour éviter de ré-inclure le fichier. |
||
| 89 | |||
| 90 | Exemple : |
||
| 91 | ```c |
||
| 92 | #ifndef _test_h |
||
| 93 | #define _test_h |
||
| 94 | /** |
||
| 95 | * @file : test.h |
||
| 96 | * @brief Description |
||
| 97 | * @version 0.00.01 |
||
| 98 | * @date 2023-02-26 |
||
| 99 | * @author Patrice Nadeau <pnadeau@patricenadeau.com> |
||
| 100 | * @copyright 2023 Patrice Nadeau |
||
| 101 | */ |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @mainpage lcd |
||
| 105 | 37 | Patrice Nadeau | * @brief ATMEL AVR 8-bit C librairie |
| 106 | 1 | Patrice Nadeau | * @author Patrice Nadeau <pnadeau@patricenadeau.com> |
| 107 | * @version 0.0.02 |
||
| 108 | * @date 2023-03-27 |
||
| 109 | 37 | Patrice Nadeau | * @pre AVR supportes (testés en gras): |
| 110 | 1 | Patrice Nadeau | * - ATmega88 |
| 111 | * - ATmega168 |
||
| 112 | 15 | Patrice Nadeau | * - **ATmega328P** |
| 113 | 1 | Patrice Nadeau | * @copyright |
| 114 | 13 | Patrice Nadeau | * @include{doc} LICENSE.txt |
| 115 | 1 | Patrice Nadeau | */ |
| 116 | |||
| 117 | ... |
||
| 118 | |||
| 119 | #endif /*_usart.h*/ |
||
| 120 | ``` |
||
| 121 | |||
| 122 | ## Commentaires |
||
| 123 | Les commentaires DOIVENT : |
||
| 124 | * Être de style « C » |
||
| 125 | * Précéder l’élément à documenté |
||
| 126 | * En minuscules et commencer par une majuscule |
||
| 127 | |||
| 128 | Exemple : |
||
| 129 | ``` c |
||
| 130 | /* Une seule ligne... */ |
||
| 131 | |||
| 132 | /* |
||
| 133 | * Sur |
||
| 134 | * plusieurs |
||
| 135 | * lignes |
||
| 136 | */ |
||
| 137 | ``` |
||
| 138 | |||
| 139 | ## Convention de noms |
||
| 140 | |||
| 141 | 30 | Patrice Nadeau | En général : *librairie*\_*action*\_*sujet* |
| 142 | 1 | Patrice Nadeau | |
| 143 | 31 | Patrice Nadeau | * Comporter au maximum **31** caractères |
| 144 | * Être séparées par des traits de soulignement si comporte plusieurs mots |
||
| 145 | * Exceptions : |
||
| 146 | * Fonction et variables DOIVENT |
||
| 147 | * Être en minuscule |
||
| 148 | * Macros, constantes et `#define` DOIVENT |
||
| 149 | * Être en majuscule |
||
| 150 | 1 | Patrice Nadeau | |
| 151 | Justification : |
||
| 152 | * Linux kernel coding style : <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#naming> |
||
| 153 | * GNU Coding Standards <https://www.gnu.org/prep/standards/html_node/Writing-C.html#Writing-C> |
||
| 154 | * Embedded C Coding Standard : <https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard> |
||
| 155 | |||
| 156 | ## Déclarations locales |
||
| 157 | |||
| 158 | Une déclaration n’ayant qu’une visibilité locale DOIT : |
||
| 159 | * Être de classe `static` |
||
| 160 | |||
| 161 | Exemple: |
||
| 162 | ``` c |
||
| 163 | /** |
||
| 164 | * @brief Local function |
||
| 165 | **/ |
||
| 166 | 7 | Patrice Nadeau | static int local_func(void) { |
| 167 | 1 | Patrice Nadeau | ... |
| 168 | return 0; |
||
| 169 | } |
||
| 170 | ``` |
||
| 171 | |||
| 172 | ## Items déconseillés et retirés |
||
| 173 | |||
| 174 | Les fonctions et variables ne devant plus être utilisés, DOIVENT générer un message lors de la compilation (*-Wall*) si un appel est effectué. |
||
| 175 | * Les attributs`__attribute__((deprecated))` ou `__attribute__((unavailable))` DOIVENT être ajoutés à la déclaration. |
||
| 176 | * La documentation DOIT indiquer les substituts à utiliser. |
||
| 177 | |||
| 178 | Exemple : |
||
| 179 | ``` c |
||
| 180 | /** |
||
| 181 | * @brief OldFunction |
||
| 182 | * @deprecated Use NewFunction instead |
||
| 183 | * @since Version x.x.xx |
||
| 184 | */ |
||
| 185 | int OldFunction(void) __attribute__((deprecated)); |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @brief OldFunction |
||
| 189 | * @deprecated Use NewFunction instead |
||
| 190 | * @since Version x.x.xx |
||
| 191 | */ |
||
| 192 | int OldFunction(void) __attribute__((unavailable)); |
||
| 193 | ``` |
||
| 194 | |||
| 195 | ## Constantes |
||
| 196 | |||
| 197 | Utilisé au lieu d’une macro quand le type ou la visibilité de la variable doit être définis. |
||
| 198 | |||
| 199 | DOIVENT être |
||
| 200 | 21 | Patrice Nadeau | * De classe `static` ou `extern` selon le besoin |
| 201 | 1 | Patrice Nadeau | |
| 202 | Exemple : |
||
| 203 | |||
| 204 | ``` c |
||
| 205 | /** |
||
| 206 | 38 | Patrice Nadeau | * @name Liste des constantes |
| 207 | 1 | Patrice Nadeau | * @brief |
| 208 | */ |
||
| 209 | /** @{ */ |
||
| 210 | 38 | Patrice Nadeau | /** @brief La chaîne d'initialisation du projet */ |
| 211 | 1 | Patrice Nadeau | static const char INIT_STR[6] = "POWER"; |
| 212 | 38 | Patrice Nadeau | /** @brief Constante globale de la librairie `random` */ |
| 213 | 1 | Patrice Nadeau | extern int RANDOM_MAX = 25; |
| 214 | /** @} */ |
||
| 215 | |||
| 216 | 38 | Patrice Nadeau | /** @brief Constante */ |
| 217 | 1 | Patrice Nadeau | const int ANSWER 42; |
| 218 | ``` |
||
| 219 | |||
| 220 | ## Énumérations |
||
| 221 | |||
| 222 | DOIT être utilisée pour définir une série de valeurs. |
||
| 223 | |||
| 224 | Exemple : |
||
| 225 | ```c |
||
| 226 | /** |
||
| 227 | * @name List of STATUS values |
||
| 228 | * @brief |
||
| 229 | * */ |
||
| 230 | enum STATUS { |
||
| 231 | /** @brief Everything is fine */ |
||
| 232 | STATUS_OK = 0, |
||
| 233 | /** @brief Initialisation in progress */ |
||
| 234 | STATUS_INIT, |
||
| 235 | /** @brief System halted */ |
||
| 236 | STATUS_HALTED |
||
| 237 | }; |
||
| 238 | ``` |
||
| 239 | |||
| 240 | ## Typedef |
||
| 241 | |||
| 242 | Format : |
||
| 243 | * En minuscule, suivie de **_t** |
||
| 244 | |||
| 245 | Exemple : |
||
| 246 | ``` c |
||
| 247 | 39 | Patrice Nadeau | /** Type de la structure dans la librairie `ds1305` */ |
| 248 | 1 | Patrice Nadeau | typedef struct { |
| 249 | 39 | Patrice Nadeau | /** @brief Dernier deux chiffres : ≥ 00, ≤ 99 */ |
| 250 | 1 | Patrice Nadeau | uint8_t year; |
| 251 | /** @brief 01 - 12 */ |
||
| 252 | uint8_t month; |
||
| 253 | /** @brief 01 - 31 */ |
||
| 254 | uint8_t date; |
||
| 255 | /** @brief 1 - 7 */ |
||
| 256 | uint8_t day; |
||
| 257 | /** @brief 00 - 23 */ |
||
| 258 | uint8_t hours; |
||
| 259 | /** @brief 00 - 59 */ |
||
| 260 | uint8_t minutes; |
||
| 261 | /** @brief 00 - 59 */ |
||
| 262 | uint8_t seconds; |
||
| 263 | } ds1305_time_t; |
||
| 264 | ``` |
||
| 265 | |||
| 266 | ## Variables |
||
| 267 | |||
| 268 | Exemple : |
||
| 269 | ``` c |
||
| 270 | /** @brief Local variable */ |
||
| 271 | static int ctr; |
||
| 272 | /** @brief Global variable */ |
||
| 273 | int random_ctr; |
||
| 274 | ``` |
||
| 275 | |||
| 276 | ## Structures |
||
| 277 | |||
| 278 | Format |
||
| 279 | * En minuscule, séparé par des «underscores» si nécessaire. |
||
| 280 | |||
| 281 | Exemple : |
||
| 282 | ``` c |
||
| 283 | /** |
||
| 284 | * @brief Structure for a local menu |
||
| 285 | * @see MenuSelect |
||
| 286 | */ |
||
| 287 | struct menu { |
||
| 288 | 8 | Patrice Nadeau | /** @brief Character used for the item */ |
| 289 | char choice; |
||
| 290 | /** @brief Description of the item */ |
||
| 291 | char *item; |
||
| 292 | 1 | Patrice Nadeau | }; |
| 293 | ``` |
||
| 294 | |||
| 295 | ## Fonctions |
||
| 296 | |||
| 297 | |||
| 298 | Le nom DOIT être dans le format suivant : *Action***_***Item***_***Attribut*, où *Action* signifie : |
||
| 299 | 29 | Patrice Nadeau | * **set**, **get**, **clear** : Règle, obtient ou vide un registre |
| 300 | 1 | Patrice Nadeau | * **read**, **write** : Lis ou écris dans un fichier |
| 301 | * **init** : Fonction d’initialisation |
||
| 302 | * **is** : Vérifie un état |
||
| 303 | 36 | Patrice Nadeau | * **setup** : Fonction de configuration des ports (AVR) |
| 304 | 1 | Patrice Nadeau | |
| 305 | Exceptions |
||
| 306 | * Les fonctions définies dans une librairie de bas niveau pour du matériel (« driver ») devraient utiliser le nom définis dans le « datasheet ». |
||
| 307 | |||
| 308 | Une fonction DEVRAIT retourner une valeur. |
||
| 309 | 28 | Patrice Nadeau | * Type entier (oui/non) : |
| 310 | 1 | Patrice Nadeau | * Succès : **0** |
| 311 | * Erreur : **1** |
||
| 312 | * Type booléen (Librairie `<stdbool.h>`) |
||
| 313 | * **true** |
||
| 314 | * **false** |
||
| 315 | * Pointeur : |
||
| 316 | * **NULL** : Erreur |
||
| 317 | * Autre valeur : adresse du pointeur |
||
| 318 | |||
| 319 | Justification : |
||
| 320 | * [AVR1000b](https://ww1.microchip.com/downloads/en/Appnotes/AVR1000b-Getting-Started-Writing-C-Code-for-AVR-DS90003262B.pdf) |
||
| 321 | |||
| 322 | Exemple : |
||
| 323 | |||
| 324 | ``` c |
||
| 325 | /** |
||
| 326 | * @brief Check if a timer is set |
||
| 327 | * @param[in] nb Timer number. @n Possible values : |
||
| 328 | 24 | Patrice Nadeau | * − @arg **TIMER_1** |
| 329 | * − @arg **TIMER_2** |
||
| 330 | 1 | Patrice Nadeau | * @return |
| 331 | 24 | Patrice Nadeau | * @retval true Timer *nb* is set |
| 332 | * @retval false Timer *nb* is NOT set |
||
| 333 | 1 | Patrice Nadeau | * @par Example : |
| 334 | * Check if the timer is set |
||
| 335 | * @code |
||
| 336 | * ... |
||
| 337 | * result = is_timer_set(); |
||
| 338 | * ... |
||
| 339 | * @endcode |
||
| 340 | * @pre init_timer |
||
| 341 | **/ |
||
| 342 | |||
| 343 | static bool is_timer_set(uint8_t nb); |
||
| 344 | |||
| 345 | ``` |
||
| 346 | |||
| 347 | 11 | Patrice Nadeau | ## Préprocesseur |
| 348 | Directives du préprocesseur gcc. |
||
| 349 | 1 | Patrice Nadeau | |
| 350 | ### #include |
||
| 351 | |||
| 352 | Pour inclure d’autres fichier comme les fichiers entête. |
||
| 353 | > N’est pas documenté dans Doxygen. |
||
| 354 | |||
| 355 | ### #ifdef / ifndef |
||
| 356 | |||
| 357 | Surtout utiliser pour des options de compilation sur différentes plateforme. |
||
| 358 | Utiliser une forme évitant les répétitions. |
||
| 359 | |||
| 360 | > N’est pas documenté dans Doxygen. |
||
| 361 | |||
| 362 | Exemple : |
||
| 363 | ```c |
||
| 364 | const char BLUE = |
||
| 365 | #if ENABLED(FEATURE_ONE) |
||
| 366 | '1' |
||
| 367 | #else |
||
| 368 | '0' |
||
| 369 | #endif |
||
| 370 | ; |
||
| 371 | ``` |
||
| 372 | |||
| 373 | ### Diagnostiques |
||
| 374 | |||
| 375 | Les macros `#warning` et `#error` sont utilisées pour afficher des avertissements (continue la compilation) ou des erreurs (arrête la compilation). |
||
| 376 | |||
| 377 | > Ne sont pas documentées dans Doxygen. |
||
| 378 | |||
| 379 | Exemple : |
||
| 380 | ``` c |
||
| 381 | #ifndef usart_AVR |
||
| 382 | #error "__FILE_NAME__ is not supported on this AVR !" |
||
| 383 | #endif |
||
| 384 | |||
| 385 | #ifndef __test__ |
||
| 386 | #warning "test is not defined !" |
||
| 387 | #endif |
||
| 388 | ``` |
||
| 389 | |||
| 390 | ### Définitions |
||
| 391 | |||
| 392 | Un `#define` est utilisé pour remplacer une valeur au moment de la compilation |
||
| 393 | > Pour la définition d'une valeur « integer », un `enum` DOIT être utilisé. |
||
| 394 | |||
| 395 | Exemple : |
||
| 396 | ``` c |
||
| 397 | /** |
||
| 398 | * @name Registers name |
||
| 399 | */ |
||
| 400 | /** @{ */ |
||
| 401 | /** @brief USART1 */ |
||
| 402 | #define USART1 REG1 |
||
| 403 | /** @brief USART2 */ |
||
| 404 | #define USART2 REG2 |
||
| 405 | /** @} */ |
||
| 406 | |||
| 407 | USART1 = 0x0F; |
||
| 408 | ``` |
||
| 409 | |||
| 410 | ## Atmel AVR |
||
| 411 | |||
| 412 | Particularités pour les microcontrôleurs 8 bits AVR d’Atmel. |
||
| 413 | |||
| 414 | [Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers](https://ww1.microchip.com/downloads/en/AppNotes/doc8453.pdf) |
||
| 415 | |||
| 416 | ### Fichier d’en-têtes |
||
| 417 | |||
| 418 | 25 | Patrice Nadeau | Vérification du modèle de microcontrôleur |
| 419 | > Via l'option `-m` de [gcc](https://github.com/embecosm/avr-gcc/blob/avr-gcc-mainline/gcc/config/avr/avr-mcus.def) |
||
| 420 | |||
| 421 | 1 | Patrice Nadeau | ```c |
| 422 | 25 | Patrice Nadeau | #ifndef defined (__AVR_ATmega48__) || (__AVR_ATmega48P__) || \ |
| 423 | (__AVR_ATmega88P__) || defined (__AVR_ATmega88__) || \ |
||
| 424 | (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || \ |
||
| 425 | (__AVR_ATmega328__) || defined (__AVR_ATmega328P__) |
||
| 426 | #warning "Cette librairie n'as pas été testée sur cette famille de microcontrôleur." |
||
| 427 | #endif |
||
| 428 | 1 | Patrice Nadeau | ``` |
| 429 | |||
| 430 | ### Macros |
||
| 431 | Liste des macros définies : |
||
| 432 | * `F_CPU` : La fréquence utilisée par l'horloge (interne ou externe) du microcontrôleur |
||
| 433 | |||
| 434 | > Les « fuses » doivent correspondent à la bonne source de l'horloge. |
||
| 435 | |||
| 436 | ### Types |
||
| 437 | |||
| 438 | De nouveau type d'entier sont fournis avec la librairie `<stdint.h>`. |
||
| 439 | |||
| 440 | L'utilisation de ces types DOIT être utilisé afin d'exprimer le nombre de bit d'un objet. |
||
| 441 | |||
| 442 | ### Progmem |
||
| 443 | Pour mettre des variables en lecture seule dans la section FLASH au lieu de SRAM avec `<avr/pgmspace.h>`. |
||
| 444 | > L’accès à ces variables est faite via les macros de la librairie. |
||
| 445 | |||
| 446 | Le nom de la variable DOIT être suivie de **_P** |
||
| 447 | |||
| 448 | Exemple : |
||
| 449 | ```c |
||
| 450 | #include <avr/pgmspace.h> |
||
| 451 | ... |
||
| 452 | /** @brief Variable en FLASH */ |
||
| 453 | const int Variable1_P PROGMEM = 42; |
||
| 454 | ``` |
||
| 455 | |||
| 456 | ### Fonction main |
||
| 457 | Un microcontrôleur AVR ne termine jamais la fonction `main`. |
||
| 458 | |||
| 459 | * Déclarer la fonction main avec l’attribut `noreturn` |
||
| 460 | * La boucle sans fin la plus optimisé est le `for (;;)` |
||
| 461 | |||
| 462 | Justification : [AVR035](https://ww1.microchip.com/downloads/en/AppNotes/doc1497.pdf) |
||
| 463 | |||
| 464 | Exemple : |
||
| 465 | ```c |
||
| 466 | 26 | Patrice Nadeau | #include <avr/io.h> |
| 467 | |||
| 468 | 1 | Patrice Nadeau | /** |
| 469 | * @brief Never ending loop |
||
| 470 | */ |
||
| 471 | 12 | Patrice Nadeau | void main(void) __attribute__ ((noreturn)); |
| 472 | 1 | Patrice Nadeau | |
| 473 | /* main function definition */ |
||
| 474 | 9 | Patrice Nadeau | void main(void) { |
| 475 | 1 | Patrice Nadeau | ... |
| 476 | /* never return */ |
||
| 477 | for (;;) { |
||
| 478 | }; |
||
| 479 | }; |
||
| 480 | ``` |
||
| 481 | |||
| 482 | ### Atomic |
||
| 483 | Opérations ne devant pas être interrompus comme charger un registre de 16 bits avec un registre de 8 bits. |
||
| 484 | |||
| 485 | La librairie `avr-libc` (util/atomic.h) fournit des macros permettant la gestion entre autre des interruptions. |
||
| 486 | |||
| 487 | Les instructions critiques sont insérées dans un `ATOMIC_BLOCK`. |
||
| 488 | |||
| 489 | Exemple : |
||
| 490 | ```c |
||
| 491 | ... |
||
| 492 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { |
||
| 493 | ... |
||
| 494 | } |
||
| 495 | ... |
||
| 496 | ``` |