Pascal for C users/fr: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Pascal for C users/fr
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## Présentation | |
| 2 | + | ||
| 3 | + | Cette page donne quelques traduction entre des concepts C(++) et Pascal. | |
| 4 | + | ||
| 5 | + | ## Traduction | |
| 6 | + | ||
| 7 | + | > **Note:** Les opérateurs logiques (AND/OR/XOR etc) sont logiques (bit à bit) ou booléens selon le types des arguments (resp. entiers ou booléen). Puisque Pascal possède un type booléen séparé depuis le début, les opérateurs booléens sur les entiers n'étaient pas nécessaires, et sont toujours logiques (bit à bit). | |
| 8 | + | ||
| 9 | + | | C | [[Pascal]] | Notes | | |
| 10 | + | |----|----|----| | |
| 11 | + | | { | [[Begin/fr|Begin]] | | | |
| 12 | + | | } | [[End/fr|End]] | | | |
| 13 | + | | = | := | [[Becomes/fr|Affectation]] | | |
| 14 | + | | == | = | [[Equal/fr|Egalité]] | | |
| 15 | + | | / | / | [[Slash/fr|Division flottante]] (division entière: [[Div/fr|div]]) | | |
| 16 | + | | % | [[Mod/fr|Mod]] | Opération **Mod**ulo | | |
| 17 | + | | ! | [[Not/fr|Not]] | NON logique | | |
| 18 | + | | != | \<\> | [[Not equal/fr|Différent de]] | | |
| 19 | + | | && | [[And/fr|And]] | ET logique | | |
| 20 | + | | \<nowiki\> | | [[Or/fr|Or]] | | |
| 21 | + | | & | [[And/fr|And]] | ET bit à bit | | |
| 22 | + | | \| | [[Or/fr|Or]] | OU bit à bit | | |
| 23 | + | | ^ | [[Xor/fr|Xor]] | OU exclusif | | |
| 24 | + | | ~ | [[Not/fr|Not]] | Complément à 1 (inversion de bits) | | |
| 25 | + | | \>\> | [[Shr/fr|Shr]] | Décalage à droite Note: shr est un **décalage logique** et non arithmétique. Si l'opérande de gauche est une valeur négative ou un type signé alors le résultat d'une opération shr peut ne pas être ce à quoi vous vous attendiez. | | |
| 26 | + | | \<\< | [[Shl]] | Décalage à gauche | | |
| 27 | + | | ++ | [[Inc/fr|Inc]] | | | |
| 28 | + | | -- | [[Dec/fr|Dec]] | | | |
| 29 | + | | /* | { ou (* | Début de [[Comments/fr|commentaire]] | | |
| 30 | + | | */ | } ou *) | Fin de commentaire | | |
| 31 | + | | // | // | Commentaire de fin de ligne (limité à une seule ligne) | | |
| 32 | + | | 0x | [[Dollar sign/fr|$]] | Préfixe pour les nombres en hexadécimal p.ex. \$FFFFFF | | |
| 33 | + | | 0 | [[&/fr|&]] | Préfixe pour les nombres en octal p.ex. &77777777 | | |
| 34 | + | | 0b | [[Percent sign/fr|%]] | Préfixe pour les nombres en binaire p.ex. %11111111 | | |
| 35 | + | | & | [[@/fr|@]] | [[@|Opérateur d'adresse]] | | |
| 36 | + | | * | [[^/fr|^]] | Voir [[Pointer/fr|Pointeur]] et [[Basic Pascal Tutorial/Chapter 5/Pointers/fr|Pointeurs]] | | |
| 37 | + | | if() | [[If/fr|If]] [[Then/fr|Then]] | | | |
| 38 | + | | if() else | [[If/fr|If]] [[Then/fr|Then]] [[Else/fr|Else]] | | | |
| 39 | + | | while | [[While/fr|While]] [[Do/fr|Do]] | | | |
| 40 | + | | do while | [[Repeat/fr|Repeat]] [[Until/fr|Until]] [[Not/fr|Not]] | | | |
| 41 | + | | | | | | |
| 42 | + | | do while ! | [[Repeat/fr|Repeat]] [[Until/fr|Until]] | | | |
| 43 | + | | for ++ | [[For/fr|For]] [[To/fr|To]] [[Do/fr|Do]] | | | |
| 44 | + | | for -- | [[For/fr|For]] [[Downto/fr|Downto]] [[Do/fr|Do]] | | | |
| 45 | + | | switch case break | [[Case/fr|Case]] [[Of/fr|Of]] [[End/fr|End]] | | | |
| 46 | + | | switch case break default | [[Case/fr|Case]] [[Of/fr|Of]] [[Else/fr|Else]] [[End/fr|End]] | | | |
| 47 | + | | const a_c_struct *arg | [[Constref/fr|Constref]] arg : a_c_struct | | | |
| 48 | + | | a_c_struct *arg | [[Var/fr|Var]] arg : a_c_struct | | | |
| 49 | + | | | | | | |
| 50 | + | ||
| 51 | + | | Type C | [[Pascal/fr|Pascal]] [[Data type|Type]] | Taille (bits) | Etendue | Notes | | |
| 52 | + | |----|----|----|----|----| | |
| 53 | + | | char | [[Char/fr|Char]] | 8-bit | | [[ASCII/fr|ASCII]] | | |
| 54 | + | | signed char | [[Shortint/fr|Shortint]] | 8-bit | -128 .. 127 | | | |
| 55 | + | | unsigned char | [[Byte/fr|Byte]] | 8-bit | 0 .. 255 | | | |
| 56 | + | | char* | [[PChar/fr|PChar]] | (32-bit) | | Pointeur sur une chaîne à zéro terminal | | |
| 57 | + | | short int | [[Smallint/fr|Smallint]] | 16-bit | -32768 .. 32767 | | | |
| 58 | + | | unsigned short int | [[Word/fr|Word]] | 16-bit | 0 .. 65535 | | | |
| 59 | + | | int | [[Integer/fr|Integer]] | (16-bit or) 32-bit | -2147483648..2147483647 | Types entiers génériques | | |
| 60 | + | | unsigned int | [[Cardinal/fr|Cardinal]] | (16-bit or) 32-bit | 0 .. 4294967295 | Types entiers génériques | | |
| 61 | + | | long int | [[Longint/fr|Longint]] | 32-bit | -2147483648..2147483647 | | | |
| 62 | + | | unsigned long int | [[Longword/fr|Longword]] | 32-bit | 0 .. 4294967295 | | | |
| 63 | + | | float | [[Single/fr|Single]] | 32-bit | 1.5E-45 .. 3.4E+38 | | | |
| 64 | + | | double | [[Double/fr|Double]] | 64-bit | 5.0E-324 .. 1.7E+308 | | | |
| 65 | + | | | | | | | | |
| 66 | + | ||
| 67 | + | | Type C | [[Pascal/fr|Pascal]] | Notes | | |
| 68 | + | |----|----|----| | |
| 69 | + | | struct { } | [[Record/fr|Record]] [[End/fr|End]] | | | |
| 70 | + | | union { } | [[Record/fr|Record]] [[Case/fr|Case]] [[Of/fr|Of]] [[End/fr|End]] | [[Case/fr|Enregistrement avec variantes]] | | |
| 71 | + | | | | | | |
| 72 | + | ||
| 73 | + | | C | [[Pascal/fr|Pascal]] | [[Unit/fr|Unité]] | | |
| 74 | + | |----|----|----| | |
| 75 | + | | abs | Abs | [[System unit/fr|System]] | | |
| 76 | + | | acos | ArcCos | [[Math unit/fr|Math]] | | |
| 77 | + | | asin | ArcSin | [[Math unit/fr|Math]] | | |
| 78 | + | | atan | ArcTan | [[System unit/fr|System]] | | |
| 79 | + | | atof | StrToFloat | [[sysutils/fr|SysUtils]] | | |
| 80 | + | | atoi | StrToInt | [[sysutils/fr|SysUtils]] | | |
| 81 | + | | atol | StrToInt | [[sysutils/fr|SysUtils]] | | |
| 82 | + | | atoll | StrToInt64 | [[sysutils/fr|SysUtils]] | | |
| 83 | + | | ceil | Ceil | [[Math unit/fr|Math]] | | |
| 84 | + | | cos | Cos | [[System unit/fr|System]] | | |
| 85 | + | | exp | Exp | [[System unit/fr|System]] | | |
| 86 | + | | floor | Floor | [[Math unit/fr|Math]] | | |
| 87 | + | | pow | Power | [[Math unit/fr|Math]] | | |
| 88 | + | | round | Round | [[System unit/fr|System]] | | |
| 89 | + | | sin | Sin | [[System unit/fr|System]] | | |
| 90 | + | | sqrt | Sqrt | [[System unit/fr|System]] | | |
| 91 | + | | strcpy | Copy | [[System unit/fr|System]] | | |
| 92 | + | | strlen | Length | [[System unit/fr|System]] | | |
| 93 | + | | tan | Tan | [[Math unit/fr|Math]] | | |
| 94 | + | | toupper | UpCase | [[System unit/fr|System]] | | |
| 95 | + | | | | | | |
| 96 | + | ||
| 97 | + | ### C++ | |
| 98 | + | ||
| 99 | + | | C++ type | [[Pascal/fr|Pascal]] | Notes | | |
| 100 | + | |----|----|----| | |
| 101 | + | | class { } | [[Class/fr|Class]] [[End/fr|End]] | | | |
| 102 | + | | class: { } | [[Class/fr|Class]]( ) [[End/fr|End]] | | | |
| 103 | + | | template \<class T\> class { } | [[Generic/fr|Generic]] = [[Class/fr|Class]]\<T\> [[End/fr|End]] | | | |
| 104 | + | | struct { } | [[Object/fr|Object]] [[End/fr|End]] | Si vous voulez des méthodes | | |
| 105 | + | | | | | | |
| 106 | + | ||
| 107 | + | ## Voir aussi | |
| 108 | + | ||
| 109 | + | - [1](http://gd.tuwien.ac.at/languages/pascal/fpc/docs-pdf/CinFreePascal.pdf) Court tutoriel qui décrit le processus d'utilisation de code C et C++ dans FreePascal, y compris l'écriture de code enveloppe. | |
| 110 | + | - [[Creating bindings for C libraries/fr|Création de liaisons pour des bibliothèques C]] | |
| 111 | + | - [[Common problems when converting C header files/fr|Problèmes courants lors de la conversion des fichiers d'entête C]] | |
| 112 | + | - [[SWIG/fr|SWIG]] | |
| 113 | + | - [“comparison of Pascal and C” on the English Wikipedia](https://en.wikipedia.org/wiki/Comparison_of_Pascal_and_C) | |
| 114 | + | ||
| 115 | + | --- | |
| 116 | + | *From the Free Pascal wiki, page "Pascal for C users/fr", as it stood on 2023-01-25 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
