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

sxdcgaq8080 阅读:19 2024-08-30 09:31:06 评论:0

在开发二维码生成器的早期阶段,我遇到了来自 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
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号