$warn: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | `{$warn}` is a [[local compiler directives|local compiler directive]] controlling emission of certain messages during compile-time. Messages do not necessarily have to be warnings, but can be messages of any kind. The directive may also promote specific messages to errors. | |
| 2 | 2 | ||
| 3 | 3 | The (local) compiler directives `{$warnings on}` and `{$warnings off}` may turn on or off emission of all *warnings* all together. | |
| 4 | 4 | ||
| 5 | 5 | ## usage | |
| 6 | 6 | ||
| 7 | 7 | `{$warn}` requires a message label and a treatment option as arguments, like this: | |
| 8 | 8 | ||
| 9 | 9 | ``` pascal | |
| 10 | 10 | {$warn 3250 off} | |
| 11 | 11 | ``` | |
| 12 | 12 | ||
| 13 | 13 | The numeric message label can be retrieved during compilation with the `-vq` option supplied on the command-line (verbosity: show message numbers). Some messages and groups of messages have an alias, too, which can be seen in the table below. | |
| 14 | 14 | ||
| 15 | 15 | Beside `{$warn 3019 on}` or `{$warn 3019 off}` and the shorthand notation `{$warn 3019 +}` and `{$warn 3019 -}` respectively, `{$warn}` may be used to promote messages to errors. `{$warn symbol_experimental error}` will make all, if any, [[Hint Directives|hints concerning experimental symbols]] become (non-fatal) errors. Depending on the selected error treatment, the compiler may stop compiling or continue, unless a threshold of errors has been reached. | |
| 16 | 16 | ||
| 17 | 17 | Note, demoting messages to errors is not possible. A `{$fatal}` error will always be fatal. | |
| 18 | 18 | ||
| 19 | 19 | ## message labels | |
| 20 | 20 | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - | ||
| 66 | - | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | - | ||
| 71 | - | ||
| 72 | - | ||
| 73 | - | ||
| 74 | - | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - | ||
| 83 | - | ||
| 84 | - | ||
| 85 | - | ||
| 86 | - | ||
| 87 | - | ||
| 88 | - | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - | ||
| 93 | - | ||
| 94 | - | ||
| 95 | - | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - | ||
| 102 | - | ||
| 103 | - | ||
| 104 | - | ||
| 105 | - | ||
| 106 | - | ||
| 107 | - | ||
| 108 | - | ||
| 109 | - | ||
| 110 | - | ||
| 111 | - | ||
| 112 | - | ||
| 113 | - | ||
| 114 | - | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - | ||
| 118 | - | ||
| 119 | - | ||
| 120 | - | ||
| 121 | - | ||
| 122 | - | ||
| 123 | - | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - | ||
| 128 | - | ||
| 129 | - | ||
| 130 | - | ||
| 131 | - | ||
| 132 | - | ||
| 133 | - | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - | ||
| 137 | - | ||
| 138 | - | ||
| 139 | - | ||
| 140 | - | ||
| 141 | - | ||
| 142 | - | ||
| 143 | - | ||
| 144 | - | ||
| 145 | - | ||
| 146 | - | ||
| 147 | - | ||
| 148 | - | ||
| 149 | - | ||
| 150 | - | ||
| 151 | - | ||
| 152 | - | ||
| 153 | - | ||
| 154 | - | ||
| 155 | - | ||
| 156 | - | ||
| 157 | - | ||
| 158 | - | ||
| 159 | - | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - | ||
| 164 | - | ||
| 165 | - | ||
| 166 | - | ||
| 167 | - | ||
| 168 | - | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - | ||
| 172 | - | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - | ||
| 176 | - | ||
| 177 | - | ||
| 178 | - | ||
| 179 | - | ||
| 180 | - | ||
| 181 | - | ||
| 182 | - | ||
| 183 | - | ||
| 184 | - | ||
| 185 | - | ||
| 186 | - | ||
| 187 | - | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | - | ||
| 192 | - | ||
| 193 | - | ||
| 194 | - | ||
| 195 | - | ||
| 196 | - | ||
| 197 | - | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - | ||
| 205 | - | ||
| 206 | - | ||
| 207 | - | ||
| 208 | - | ||
| 209 | - | ||
| 210 | - | ||
| 211 | - | ||
| 212 | - | ||
| 213 | - | ||
| 214 | - | ||
| 215 | - | ||
| 216 | - | ||
| 217 | - | ||
| 218 | - | ||
| 219 | - | ||
| 220 | - | ||
| 221 | - | ||
| 222 | - | ||
| 223 | - | ||
| 224 | - | ||
| 225 | - | ||
| 226 | - | ||
| 227 | - | ||
| 228 | - | ||
| 229 | - | ||
| 230 | - | ||
| 231 | - | ||
| 232 | - | ||
| 233 | - | ||
| 234 | - | ||
| 235 | - | ||
| 236 | - | ||
| 237 | - | ||
| 238 | - | ||
| 239 | - | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - | ||
| 243 | - | ||
| 244 | - | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - | ||
| 248 | - | ||
| 249 | - | ||
| 250 | - | ||
| 251 | - | ||
| 252 | - | ||
| 253 | - | ||
| 254 | - | ||
| 255 | - | ||
| 256 | - | ||
| 257 | - | ||
| 258 | - | ||
| 259 | - | ||
| 260 | - | ||
| 261 | - | ||
| 262 | - | ||
| 263 | - | ||
| 264 | - | ||
| 265 | - | ||
| 266 | - | ||
| 267 | - | ||
| 268 | - | ||
| 269 | - | ||
| 270 | - | ||
| 271 | - | ||
| 272 | - | ||
| 273 | - | ||
| 274 | - | ||
| 275 | - | ||
| 276 | - | ||
| 277 | - | ||
| 278 | - | ||
| 279 | - | ||
| 280 | - | ||
| 281 | - | ||
| 282 | - | ||
| 283 | - | ||
| 284 | - | ||
| 285 | - | ||
| 286 | - | ||
| 287 | - | ||
| 288 | - | ||
| 289 | - | ||
| 290 | - | ||
| 291 | - | ||
| 292 | - | ||
| 293 | - | ||
| 294 | - | ||
| 295 | - | ||
| 296 | - | ||
| 297 | - | ||
| 298 | - | ||
| 299 | - | ||
| 300 | - | ||
| 301 | - | ||
| 302 | - | ||
| 303 | - | ||
| 304 | - | ||
| 305 | - | ||
| 306 | - | ||
| 307 | - | ||
| 308 | - | ||
| 309 | - | ||
| 310 | - | ||
| 311 | - | ||
| 312 | - | ||
| 21 | + | [[FPC]] messages (excerpt) | |
| 22 | + | ||
| 23 | + | **index** | |
| 24 | + | ||
| 25 | + | **alias** | |
| 26 | + | ||
| 27 | + | **situations triggering the message** | |
| 28 | + | ||
| 29 | + | `02024` | |
| 30 | + | ||
| 31 | + | - there is a custom defined `{$warning}` | |
| 32 | + | ||
| 33 | + | `02077` | |
| 34 | + | ||
| 35 | + | - the directive `{$minStackSize}` is used, but not supported on the current OS | |
| 36 | + | ||
| 37 | + | `02078` | |
| 38 | + | ||
| 39 | + | - the directive `{$maxStackSize}` is used, but not supported on the current OS | |
| 40 | + | ||
| 41 | + | `03018` | |
| 42 | + | ||
| 43 | + | - a `constructor` is not defined at `public` visibility level | |
| 44 | + | ||
| 45 | + | `03019` | |
| 46 | + | ||
| 47 | + | - a `destructor` is not defined at `public` visibility level | |
| 48 | + | ||
| 49 | + | `03177` | |
| 50 | + | ||
| 51 | + | - a `record` initialization does not define values for all fields | |
| 52 | + | ||
| 53 | + | `03211` | |
| 54 | + | ||
| 55 | + | `implicit_variants` | |
| 56 | + | ||
| 57 | + | - the `variants` unit is required, but has not yet been loaded | |
| 58 | + | ||
| 59 | + | `03250` | |
| 60 | + | ||
| 61 | + | - a virtual method is overridden with lower visibility | |
| 62 | + | ||
| 63 | + | `04044` | |
| 64 | + | ||
| 65 | + | - a comparison might be always `false` (disjunct ranges) | |
| 66 | + | ||
| 67 | + | `04045` | |
| 68 | + | ||
| 69 | + | - a comparison might be always `true` (disjunct ranges) | |
| 70 | + | ||
| 71 | + | `04046` | |
| 72 | + | ||
| 73 | + | `constructing_abstract` | |
| 74 | + | ||
| 75 | + | - constructing an instance of a class with abstract methods | |
| 76 | + | ||
| 77 | + | `04056` | |
| 78 | + | ||
| 79 | + | - a pointer to ordinal conversion is not portable | |
| 80 | + | ||
| 81 | + | `04090` | |
| 82 | + | ||
| 83 | + | `zero_nil_compat` | |
| 84 | + | ||
| 85 | + | - converting `0` to [[Nil|nil]] (integer to pointer) | |
| 86 | + | ||
| 87 | + | `04104` | |
| 88 | + | ||
| 89 | + | `implicit_string_cast` | |
| 90 | + | ||
| 91 | + | - implicit string type conversion | |
| 92 | + | ||
| 93 | + | `04105` | |
| 94 | + | ||
| 95 | + | `implicit_string_cast_loss` | |
| 96 | + | ||
| 97 | + | - implicit string type conversion with potential data loss | |
| 98 | + | ||
| 99 | + | `04106` | |
| 100 | + | ||
| 101 | + | `explicit_string_cast` | |
| 102 | + | ||
| 103 | + | - explicit string type conversion | |
| 104 | + | ||
| 105 | + | `04107` | |
| 106 | + | ||
| 107 | + | `explicit_string_cast_loss` | |
| 108 | + | ||
| 109 | + | - explicit string type conversion with potential data loss | |
| 110 | + | ||
| 111 | + | `04108` | |
| 112 | + | ||
| 113 | + | `cvt_narrowing_string_lost` | |
| 114 | + | ||
| 115 | + | - Unicode constant cast with potential data loss | |
| 116 | + | ||
| 117 | + | `04116` | |
| 118 | + | ||
| 119 | + | `intf_raise_visibility` | |
| 120 | + | ||
| 121 | + | - the interface defines a broader visibility for a method | |
| 122 | + | ||
| 123 | + | `04122` | |
| 124 | + | ||
| 125 | + | `constructing_abstract` | |
| 126 | + | ||
| 127 | + | - constructing an instance of an abstract class | |
| 128 | + | ||
| 129 | + | `05023` | |
| 130 | + | ||
| 131 | + | - a `unit` is imported, but not used (except units containing `initialization`/`finalization` code) | |
| 132 | + | ||
| 133 | + | `05024` | |
| 134 | + | ||
| 135 | + | - a routine parameter remains unused | |
| 136 | + | ||
| 137 | + | `05033` | |
| 138 | + | ||
| 139 | + | `no_retval` | |
| 140 | + | ||
| 141 | + | - no (for the compiler obvious) assignment to a function’s return value | |
| 142 | + | ||
| 143 | + | `05036` | |
| 144 | + | ||
| 145 | + | - a variable which might not yet have been initialized is used | |
| 146 | + | ||
| 147 | + | `05043` | |
| 148 | + | ||
| 149 | + | `symbol_deprecated` | |
| 150 | + | ||
| 151 | + | - a symbol with the `deprecated` hint (no deprecation message defined) is used | |
| 152 | + | ||
| 153 | + | `05044` | |
| 154 | + | ||
| 155 | + | `symbol_platform` | |
| 156 | + | ||
| 157 | + | - a symbol with the `platform` hint is used | |
| 158 | + | ||
| 159 | + | `05055` | |
| 160 | + | ||
| 161 | + | `symbol_unimplemented` | |
| 162 | + | ||
| 163 | + | - a symbol with the `unimplemented` hint is used | |
| 164 | + | ||
| 165 | + | `05059` | |
| 166 | + | ||
| 167 | + | - inside a function definition its result variable’s value is used, before it has been initialized | |
| 168 | + | ||
| 169 | + | `05063` | |
| 170 | + | ||
| 171 | + | `symbol_experimental` | |
| 172 | + | ||
| 173 | + | - a symbol with the `experimental` hint is used | |
| 174 | + | ||
| 175 | + | `05065` | |
| 176 | + | ||
| 177 | + | `symbol_library` | |
| 178 | + | ||
| 179 | + | - a library symbol is used | |
| 180 | + | ||
| 181 | + | `05066` | |
| 182 | + | ||
| 183 | + | `symbol_deprecated` | |
| 184 | + | ||
| 185 | + | - a symbol with the `deprecated` hint is used and a custom deprecation notice has been defined | |
| 186 | + | ||
| 187 | + | `05073` | |
| 188 | + | ||
| 189 | + | - a `private property` remains unused | |
| 190 | + | ||
| 191 | + | `05074` | |
| 192 | + | ||
| 193 | + | `unit_deprecated` | |
| 194 | + | ||
| 195 | + | - a unit with the `deprecated` hint (without a custom deprecation message supplied) is used | |
| 196 | + | ||
| 197 | + | `05075` | |
| 198 | + | ||
| 199 | + | `unit_deprecated` | |
| 200 | + | ||
| 201 | + | - a unit with the `deprecated` hint is used and a custom deprecation notice has been defined | |
| 202 | + | ||
| 203 | + | `05076` | |
| 204 | + | ||
| 205 | + | `unit_platform` | |
| 206 | + | ||
| 207 | + | - a unit with the `platform` hint is used | |
| 208 | + | ||
| 209 | + | `05077` | |
| 210 | + | ||
| 211 | + | `unit_library` | |
| 212 | + | ||
| 213 | + | - \[to be explained\] | |
| 214 | + | ||
| 215 | + | `05078` | |
| 216 | + | ||
| 217 | + | `unit_unimplemented` | |
| 218 | + | ||
| 219 | + | - a unit with the `unimplemented` hint is used | |
| 220 | + | ||
| 221 | + | `05079` | |
| 222 | + | ||
| 223 | + | `unit_experimental` | |
| 224 | + | ||
| 225 | + | - a unit with the `experimental` hint is used | |
| 226 | + | ||
| 227 | + | `06018` | |
| 228 | + | ||
| 229 | + | - the compiler has determined there is, or might be, unreachable code | |
| 230 | + | ||
| 231 | + | `07104` | |
| 232 | + | ||
| 233 | + | - register indirect addressing with `ebp` is used in conjunction with a negative offset | |
| 313 | 234 | ||
| 314 | 235 | Note, some aliases identify *multiple* messages. | |
| 315 | 236 | ||
| 316 | 237 | ## see also | |
| 317 | 238 | ||
| 318 | 239 | - [§ “`$WARN`: Control emission of warnings” in the *Free Pascal programmer’s guide*](https://www.freepascal.org/docs-html/prog/progsu80.html) | |
| 319 | 240 | - [[$message|{$message}]] | |
| 320 | 241 | - [[Turn warnings and hints on or off]] | |
| 321 | 242 | ||
| 322 | 243 | --- | |
| 323 | 244 | *From the Free Pascal wiki, page "$warn", as it stood on 2022-09-07 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).* | |
| 324 | 245 | Category: FPC | |
| 325 | 246 | Category: Local compiler directives |
