如果你想使用 GNAT 作为一个合适的 Ada 编译器,你至少应该传递这些参数:
- "-fstack-check", -- 生成堆栈检查代码(Ada 的一部分)
- "-gnata", -- 启用断言(Ada 的一部分)
- "-gnato", -- 溢出检查(Ada 的一部分)
我个人已经编写了这个项目文件,我用它来将我的首选参数设置为 GNAT:
-- O mighty Emacs, please use -*- Ada -*- mode in this lowly file.
abstract project Ada_2012 is
for Source_Dirs use ();
package Builder is
for Default_Switches ("Ada")
use ("-m");
end Builder;
package Compiler is
for Default_Switches ("Ada")
use ("-fstack-check", -- Generate stack checking code (part of Ada)
"-gnata", -- Enable assertions (part of Ada)
"-gnato13", -- Overflow checking (part of Ada)
"-gnatf", -- Full, verbose error messages
"-gnatwa", -- All optional warnings
"-gnatVa", -- All validity checks
"-gnaty3abcdefhiklmnoOprstux", -- Style checks
"-gnatwe", -- Treat warnings as errors
"-gnat2012", -- Use Ada 2012
"-Wall", -- All GCC warnings
"-O2"); -- Optimise (level 2/3)
end Compiler;
end Ada_2012;
我在我的所有 Ada (2012) 项目文件中“使用”这个文件,以便轻松访问我的标准设置。这是一个示例(来自http://repositories.jacob-sparre.dk/lego-tools):
-- O mighty Emacs, please use -*- Ada -*- mode in this lowly file.
with "ada_2012";
project LEGO_Tools is
for Source_Dirs use ("src/",
"../../Mathematics_and_Statistics/**");
for Main use ("build_mpd_file",
"fractal_landscape",
"outline_boundaries",
"pgm_to_ldraw",
"split_ldraw_file");
package Builder renames Ada_2012.Builder;
package Compiler renames Ada_2012.Compiler;
for Object_Dir use "obj/";
for Exec_Dir use "bin/";
end LEGO_Tools;