linux - 关于使用 Ada 的包体要求的令人费解的 "info"消息?

标签 linux compiler-warnings ada ada2012

在开发二维码生成器的早期阶段,我遇到了来自 GNAT 7.4.0(在“Ubuntu 19.04”系统上运行)的特殊“信息”消息。

我正在使用一些相当激进的编译开关:

gnatmake -gnata -gnateE -gnateF -gnatf -gnato -gnatv -gnatVa -gnaty -gnatwe -gnatw.e main.adb

我的代码构建没有错误,但此信息消息确实表明我没有为包“qr_symbol”提供主体。

qr_symbol.ads

with QR_Versions; use QR_Versions;

generic
   Ver : QR_Version;
package QR_Symbol is
   procedure Export_As_SVG;
private
   type Module_State is (
     Uncommitted,
     One,
     Zero
     );

   type Module_Family is (
     Uncommitted,
     Finder,
     Separator,
     Alignment,
     Timing,
     Format_Spec,
     Version_Spec,
     Data_Codeword,
     EC_Codeword,
     Padding
     );

   type Module is
      record
         State : Module_State := Uncommitted;
         Family : Module_Family := Uncommitted;
      end record;

   type Module_Matrix is array (
     Positive range <>,
     Positive range <>
     ) of Module;

end QR_Symbol;

qr_symbol.adb

with Ada.Text_IO; use Ada.Text_IO;

package body QR_Symbol is
   Version : constant QR_Version := Ver; --  Ver is a formal generic parameter
   Side_Length : constant Positive := 17 + (Positive (Ver) * 4);
   Matrix : Module_Matrix (1 .. Side_Length, 1 .. Side_Length);

   procedure Export_As_SVG is
   begin
      Put_Line ("in Export_As_SVG()...");
      Put_Line ("  Version: " & Version'Image);
      Put_Line ("  Side_Length: " & Side_Length'Image);

      --  Matrix (1, 1).State := One;
      Put_Line ("  Matrix (1, 1).State: " & Matrix (1, 1).State'Image);

   end Export_As_SVG;
end QR_Symbol;

And here's the info output that I do not understand...

GNAT 7.4.0
Copyright 1992-2017, Free Software Foundation, Inc.

Compiling: qr_symbol.adb
Source file time stamp: 2019-12-07 16:29:37
Compiled at: 2019-12-07 16:29:38

==============Error messages for source file: qr_symbol.ads
     9.    procedure Export_As_SVG;
                     |
        >>> info: "QR_Symbol" requires body ("Export_As_SVG" requires completion)

 29 lines: No errors, 1 info message
aarch64-linux-gnu-gnatbind-7 -x main.ali
aarch64-linux-gnu-gnatlink-7 main.ali

Program output (given correct input, does gives correct output)...

$ ./main '' V1
QR Version requested: V 1
in Export_As_SVG()...
  Version:  1
  Side_Length:  21
  Matrix (1, 1).State: UNCOMMITTED

问题: 为什么明明我已经这样做了,却出现提示我需要为此包提供主体的信息消息?

最佳答案

信息消息不用于建议您更改程序,仅用于提供一些(有用或无用)信息。在你的情况下,信息是真实的。如果它没有被满足,它就会变成一个错误。

您可能想检查此标志是否导致此消息的生成:

根据 GNAT User's Guide :

-gnatw.e `Activate every optional warning.'

This switch activates all optional warnings, including those which are not activated by -gnatwa. The use of this switch is not recommended for normal use. If you turn this switch on, it is almost certain that you will get large numbers of useless warnings. The warnings that are excluded from -gnatwa are typically highly specialized warnings that are suitable for use only in code that has been specifically designed according to specialized coding rules.

如果你不想删除那个开关,至少你可以禁用这个特定的信息消息:

-gnatw.Y

`Disable information messages for why package spec needs body.'

This switch suppresses the output of information messages showing why a package specification needs a body.

关于linux - 关于使用 Ada 的包体要求的令人费解的 "info"消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59228230/

相关文章:

c++ - 使用 gcc 4.1.2 抑制代码块的警告?

c++ - 我应该使用哪些编译标志来避免运行时错误

c++ - 不确定 -Wconversion 行为

ada - 使用 GtkAda 发出信号

ubuntu - 从 GPS 链接到 Ubuntu .a 模块库?

regex - linux + 不规则表达式查找机制(查找命令)或 perl

linux - 嵌入式linux子进程创建问题

linux - 是否可以提取程序中指令特定的能耗?

linux - 大小规则在 logrotate 中不起作用

exception - 我在 Ada 中收到 TASKING_ERROR 错误