From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6ea75cb98c3c832d X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: [Q] pragma Warnings Date: Wed, 28 Nov 2007 14:56:34 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1196276028.10481.19.camel@kartoffel> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1196279795 7470 192.74.137.71 (28 Nov 2007 19:56:35 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 28 Nov 2007 19:56:35 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:lvSC6dhob734xsPQicLuquq1D+Q= Xref: g2news1.google.com comp.lang.ada:18663 Date: 2007-11-28T14:56:34-05:00 List-Id: Georg Bauhaus writes: > In http://www.adacore.com/2007/11/19/ada-gem-18/ > Bob Duff explains how to use GNAT's pragma Warnings. Thanks for advertising my "gem". :-) It's not the most interesting gem, IMHO. > The effect is that GNAT users can control individual > warnings by placing suitably crafted pragmas in > source code, next to the lines that trigger the warning. > > Another effect is that some Ada programs are used with > two or more targets and are translated using two or more > different compilers. In this case, the non-GNAT compiler > might complain about a non-supported pragma Warnings. > Placing the pragmas in the source will then defeat > the pragma's purpose because the compiler will issue > a warning about an unknown Warnings pragma. (Hopefully, > the other compiler will not report an error message, > as is predictably the case with link library pragmas.) Compilers are supposed to accept programs with unrecognized pragmas, and generate runnable code. They are also supposed to warn about unrecognized pragmas, but there is normally a switch to turn that off. I've developed Ada code using multiple Ada compilers at the same time. You're right -- different Ada compilers give different warnings. Here's what I suggest: pick one of the compilers that gives the warnings you like, and take those ones seriously. For the other Ada compiler(s), turn off all warnings with a switch, or simply don't pay any attention to them (including the warnings about pragma Warnings, if any!). If you distribute source code, you should document your policy, so users understand whether or not a warning is an indication that something is wrong. > Is there an alternative to placing compiler specific > pragma Warnings in portable (pragma-wise) Ada programs? > > (E.g., using the pragma as a configuration pragma, > in a connected region of source code but not right in it? > Using a smart IDE's filtering capabilities?) In GNAT, you can use pragma Warnings as a configuration pragma, but not for specific warnings on specific lines. E.g. you can disable all warnings about uninitialized variables, but you can't disable a warning on a particular variable using a config pragma. - Bob