Gem #18: Warnings in GNAT Author: Bob Duff, AdaCore Abstract: Ada Gem #18 This gem is not about the Ada language, but about a set of GNAT-specific features related to warnings. We discuss how to make the best use of GNAT s warnings. Let s get started ¦ The recent gems about pragma No_Return talked a lot about compile-time checks that generate warnings. Indeed, GNAT is capable of generating lots of useful warnings. Here is some advice about how to get the most out of these warnings. What s the difference between a warning and an error ? First, errors are generally violations of the Ada language rules as specified in the Ada Reference Manual; warnings are GNAT specific. Thus, other Ada compilers might not warn about the same things that GNAT does. Second, warnings are typically conservative; that is, some warnings will be false alarms, and the programmer needs to study the code to see if the warning is a real problem. Some warnings are given by default, whereas some are given only if a switch enables them. Use the -gnatwa switch to turn on (almost) all warnings. Warnings are useless if you
/lp/association-for-computing-machinery/gem-18-warnings-in-gnat-ArqJe7rS5N